Skip to content

Commit

Permalink
fix: return empty catalog name (#174)
Browse files Browse the repository at this point in the history
* fix: return empty catalog name

The JDBC connection would return the current database name as the
current catalog name, but that catalog name would not be returned
in the ResultSet returned by getCatalogs(). This discrepancy causes
some tools to ignore or misinterpret the catalog and schema structure
of a Cloud Spanner database. Specifically, it breaks the autocomplete
feature of DBeaver.

* tests: fix failing test case
  • Loading branch information
olavloite committed Jun 30, 2020
1 parent 7c336d0 commit cedd167
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Expand Up @@ -291,7 +291,7 @@ public void setCatalog(String catalog) throws SQLException {
@Override
public String getCatalog() throws SQLException {
checkClosed();
return getConnectionOptions().getDatabaseName();
return "";
}

@Override
Expand Down
Expand Up @@ -634,7 +634,9 @@ public void testCatalog() throws SQLException {
ConnectionOptions options = mock(ConnectionOptions.class);
when(options.getDatabaseName()).thenReturn("test");
try (JdbcConnection connection = createConnection(options)) {
assertThat(connection.getCatalog()).isEqualTo("test");
// The connection should always return the empty string as the current catalog, as no other
// catalogs exist in the INFORMATION_SCHEMA.
assertThat(connection.getCatalog()).isEqualTo("");
// This should be allowed.
connection.setCatalog("");
try {
Expand Down

0 comments on commit cedd167

Please sign in to comment.