Skip to content

Commit e7b20eb

Browse files
authored
fix: run DatabaseMetadata tests for PG on emulator (#2271)
* test: run DatabaseMetadata tests for PG on emulator Run the DatabaseMetadata integration tests for PostgreSQL-dialect databases on the emulator. * fix: add explicit casts to function arguments
1 parent 7855076 commit e7b20eb

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/resources/com/google/cloud/spanner/jdbc/postgresql/DatabaseMetaData_GetColumns.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ SELECT TABLE_CATALOG AS "TABLE_CAT", TABLE_SCHEMA AS "TABLE_SCHEM", TABLE_NAME A
3232
WHEN DATA_TYPE LIKE 'ARRAY' THEN
3333
CASE
3434
WHEN spanner_type LIKE '%[]' THEN
35-
CONCAT('_', REPLACE(spanner_type, '[]', ''))
35+
CONCAT('_'::varchar, REPLACE(spanner_type, '[]'::varchar, ''::varchar))
3636
ELSE spanner_type
3737
END
3838
ELSE DATA_TYPE

src/test/java/com/google/cloud/spanner/jdbc/it/ITJdbcPgNumericTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ public void testResultSet() throws SQLException {
182182
assertEquals(new BigDecimal(negativeBigNumeric), resultSet.getBigDecimal("col1"));
183183
assertEquals(new BigDecimal(negativeBigNumeric), resultSet.getObject("col1"));
184184
assertEquals(Value.pgNumeric(negativeBigNumeric), resultSet.getObject("col1", Value.class));
185+
186+
// Just verify that the getColumns method works
187+
try (ResultSet columns = connection.getMetaData().getColumns(null, null, null, null)) {
188+
//noinspection StatementWithEmptyBody
189+
while (columns.next()) {
190+
// ignore
191+
}
192+
}
185193
}
186194
}
187195

0 commit comments

Comments
 (0)