getExpectedJdbcType
MSSQL-specific deviations from the default type mapping, all of them cases where the default mapping and the values ResultSet.getObject returns disagreed (see #2087):
DATETIMEOFFSETis reported with the driver-specific JDBC type-155andmicrosoft.sql.DateTimeOffsetas its column class, which the default mapping has no entry for, so it fell back toStringwhile the driver returned aDateTimeOffset. It is read asOffsetDateTime: a JDK type that keeps the UTC offset of the value, and the one the default mapping already uses forjava.sql.Types.TIMESTAMP_WITH_TIMEZONE. The driver produces it directly, seegetValueFromResultSet.Any column the driver reports
java.lang.Shortfor is read asShort, because that is what it then returns, while the default mapping declared itInt. Under MSSQL those columns areSMALLINTandTINYINT;Shortis also the smallest Kotlin type that fits MSSQL'sTINYINT, which — unlike in most databases — is unsigned (0..255) and so does not fit aByte. This branch deliberately keys on the reported column class and not onTableColumnMetadata.jdbcType: H2 in MSSQL mode delegates its mapping here, and itsSMALLINTis reported asjava.sql.Types.SMALLINTtoo but comes back as anInteger, so keying on the JDBC type would type that columnShortand make reading it throw.SQL_VARIANTholds a value of any base type, and the class of that value differs from row to row (anIntforCAST(1 AS SQL_VARIANT), aStringfor a string), so the column can only honestly be typedAny. The default mapping declared itString.