Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1290,6 +1290,44 @@ public ResultSet getTypeInfo() {
.set("NUM_PREC_RADIX")
.to(10)
.build(),
Struct.newBuilder()
.set("TYPE_NAME")
.to("UUID")
.set("DATA_TYPE")
.to(Types.OTHER) // There's no JDBC-specific type code for UUID.
.set("PRECISION")
.to((Long) null)
.set("LITERAL_PREFIX")
.to("UUID ")
.set("LITERAL_SUFFIX")
.to((String) null)
.set("CREATE_PARAMS")
.to((String) null)
.set("NULLABLE")
.to(DatabaseMetaData.typeNullable)
.set("CASE_SENSITIVE")
.to(false)
.set("SEARCHABLE")
.to(DatabaseMetaData.typeSearchable)
.set("UNSIGNED_ATTRIBUTE")
.to(true)
.set("FIXED_PREC_SCALE")
.to(false)
.set("AUTO_INCREMENT")
.to(false)
.set("LOCAL_TYPE_NAME")
.to("UUID")
.set("MINIMUM_SCALE")
.to(0)
.set("MAXIMUM_SCALE")
.to(0)
.set("SQL_DATA_TYPE")
.to((Long) null)
.set("SQL_DATETIME_SUB")
.to((Long) null)
.set("NUM_PREC_RADIX")
.to((Long) null)
.build(),
getJsonType(connection.getDialect()))),
// Allow column 2 to be cast to short without any range checks.
ImmutableSet.of(2));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ SELECT TABLE_CATALOG AS TABLE_CAT, TABLE_SCHEMA AS TABLE_SCHEM, TABLE_NAME, COLU
WHEN SPANNER_TYPE LIKE 'STRING%' THEN -9
WHEN SPANNER_TYPE = 'JSON' THEN -9
WHEN SPANNER_TYPE = 'TIMESTAMP' THEN 93
WHEN SPANNER_TYPE = 'UUID' THEN 1111
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Type code 1111 is the JDBC-code for Other. There is no specific type code for UUID in JDBC.

ELSE 1111
END AS DATA_TYPE,
SPANNER_TYPE AS TYPE_NAME,
CASE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,10 @@ public void testGetTypeInfo() throws SQLException {
assertEquals(Types.NUMERIC, rs.getInt("DATA_TYPE"));
assertEquals(Types.NUMERIC, rs.getShort("DATA_TYPE"));
assertTrue(rs.next());
assertEquals("UUID", rs.getString("TYPE_NAME"));
assertEquals(Types.OTHER, rs.getInt("DATA_TYPE"));
assertEquals(Types.OTHER, rs.getShort("DATA_TYPE"));
assertTrue(rs.next());
if (dialect == Dialect.POSTGRESQL) {
assertEquals("JSONB", rs.getString("TYPE_NAME"));
assertEquals(PgJsonbType.VENDOR_TYPE_NUMBER, rs.getInt("DATA_TYPE"));
Expand Down