Skip to content

Commit 2a7543b

Browse files
committed
Add int
1 parent 6645672 commit 2a7543b

1 file changed

Lines changed: 34 additions & 0 deletions

File tree

java-bigquery/google-cloud-bigquery-jdbc/src/test/java/com/google/cloud/bigquery/jdbc/it/ITDatabaseMetadataTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,40 @@ public void testTableConstraints() throws SQLException {
341341
connection.close();
342342
}
343343

344+
@Test
345+
public void testMetadataResultSetsDoNotInterfere() throws SQLException {
346+
try (Connection connection =
347+
DriverManager.getConnection(String.format(connectionUrl, DEFAULT_CATALOG))) {
348+
DatabaseMetaData metaData = connection.getMetaData();
349+
350+
// Get primary keys for table 1
351+
ResultSet primaryKeys1 =
352+
metaData.getPrimaryKeys(PROJECT_ID, CONSTRAINTS_DATASET, CONSTRAINTS_TABLE_NAME);
353+
354+
// Get imported keys for table 1, BEFORE fully consuming primaryKeys1
355+
ResultSet importedKeys =
356+
metaData.getImportedKeys(PROJECT_ID, CONSTRAINTS_DATASET, CONSTRAINTS_TABLE_NAME);
357+
358+
// Now try to read from primaryKeys1
359+
Assertions.assertTrue(primaryKeys1.next());
360+
Assertions.assertEquals("id", primaryKeys1.getString("COLUMN_NAME"));
361+
362+
// Read from importedKeys
363+
Assertions.assertTrue(importedKeys.next());
364+
Assertions.assertEquals(CONSTRAINTS_TABLE_NAME2, importedKeys.getString("PKTABLE_NAME"));
365+
366+
// Read more from primaryKeys1 (should be finished now)
367+
Assertions.assertFalse(primaryKeys1.next());
368+
369+
// Read more from importedKeys
370+
Assertions.assertTrue(importedKeys.next());
371+
Assertions.assertEquals(CONSTRAINTS_TABLE_NAME2, importedKeys.getString("PKTABLE_NAME"));
372+
373+
primaryKeys1.close();
374+
importedKeys.close();
375+
}
376+
}
377+
344378
@Test
345379
public void testDatabaseMetadataGetCatalogs() throws SQLException {
346380

0 commit comments

Comments
 (0)