Repository: googleapis/java-spanner-jdbc
Pull request #1733 (2024-08-28 14:44:22)

feat: update DatabaseMetaData to include named schemas
Updates the results that we return for methods that relate to named schemas in `DatabaseMetaData`,  as Spanner now supports named schemas.


Patch:
diff --git a/samples/quickperf/pom.xml b/samples/quickperf/pom.xml
index 181a763..4c83a3f 100644
--- a/samples/quickperf/pom.xml
+++ b/samples/quickperf/pom.xml
@@ -27,7 +27,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.44.0</version>
+        <version>26.45.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -52,11 +52,17 @@
     <dependency>
       <groupId>com.google.cloud</groupId>
       <artifactId>google-cloud-spanner-jdbc</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>com.google.api.grpc</groupId>
+          <artifactId>proto-google-cloud-spanner-executor-v1</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.apache.commons</groupId>
       <artifactId>commons-lang3</artifactId>
-      <version>3.16.0</version>
+      <version>3.17.0</version>
     </dependency>
     <dependency>
       <groupId>com.fasterxml.jackson.core</groupId>
diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml
index 2d0ed28..d78984e 100644
--- a/samples/snippets/pom.xml
+++ b/samples/snippets/pom.xml
@@ -26,7 +26,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.44.0</version>
+        <version>26.45.0</version>
         <type>pom</type>
         <scope>import</scope>
       </dependency>
@@ -37,6 +37,12 @@
     <dependency>
       <groupId>com.google.cloud</groupId>
       <artifactId>google-cloud-spanner-jdbc</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>com.google.api.grpc</groupId>
+          <artifactId>proto-google-cloud-spanner-executor-v1</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <!-- [END spanner-jdbc_install_with_bom] -->
 
diff --git a/samples/spring-data-jdbc/pom.xml b/samples/spring-data-jdbc/pom.xml
index 733e571..5a8b486 100644
--- a/samples/spring-data-jdbc/pom.xml
+++ b/samples/spring-data-jdbc/pom.xml
@@ -37,7 +37,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.44.0</version>
+        <version>26.45.0</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
@@ -62,7 +62,12 @@
     <dependency>
       <groupId>com.google.cloud</groupId>
       <artifactId>google-cloud-spanner-jdbc</artifactId>
-      <version>2.21.0</version>
+      <exclusions>
+        <exclusion>
+          <groupId>com.google.api.grpc</groupId>
+          <artifactId>proto-google-cloud-spanner-executor-v1</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.postgresql</groupId>
diff --git a/samples/spring-data-mybatis/pom.xml b/samples/spring-data-mybatis/pom.xml
index 8a13c6b..624f846 100644
--- a/samples/spring-data-mybatis/pom.xml
+++ b/samples/spring-data-mybatis/pom.xml
@@ -35,7 +35,7 @@
       <dependency>
         <groupId>com.google.cloud</groupId>
         <artifactId>libraries-bom</artifactId>
-        <version>26.44.0</version>
+        <version>26.45.0</version>
         <scope>import</scope>
         <type>pom</type>
       </dependency>
@@ -58,6 +58,12 @@
     <dependency>
       <groupId>com.google.cloud</groupId>
       <artifactId>google-cloud-spanner-jdbc</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>com.google.api.grpc</groupId>
+          <artifactId>proto-google-cloud-spanner-executor-v1</artifactId>
+        </exclusion>
+      </exclusions>
     </dependency>
     <dependency>
       <groupId>org.postgresql</groupId>
diff --git a/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java b/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java
index 7bafb2f..6cb6f3e 100644
--- a/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java
+++ b/src/main/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaData.java
@@ -419,27 +419,27 @@ class JdbcDatabaseMetaData extends AbstractJdbcWrapper implements DatabaseMetaDa
 
   @Override
   public boolean supportsSchemasInDataManipulation() {
-    return false;
+    return true;
   }
 
   @Override
   public boolean supportsSchemasInProcedureCalls() {
-    return false;
+    return true;
   }
 
   @Override
   public boolean supportsSchemasInTableDefinitions() {
-    return false;
+    return true;
   }
 
   @Override
   public boolean supportsSchemasInIndexDefinitions() {
-    return false;
+    return true;
   }
 
   @Override
   public boolean supportsSchemasInPrivilegeDefinitions() {
-    return false;
+    return true;
   }
 
   @Override
@@ -602,7 +602,7 @@ class JdbcDatabaseMetaData extends AbstractJdbcWrapper implements DatabaseMetaDa
 
   @Override
   public int getMaxSchemaNameLength() {
-    return 0;
+    return 128;
   }
 
   @Override


Test patch:
diff --git a/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java b/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java
index 64499f4..193fc96 100644
--- a/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java
+++ b/src/test/java/com/google/cloud/spanner/jdbc/JdbcDatabaseMetaDataTest.java
@@ -112,7 +112,7 @@ public class JdbcDatabaseMetaDataTest {
     assertEquals(8000, meta.getMaxIndexLength());
     assertEquals(0, meta.getMaxProcedureNameLength());
     assertEquals(0, meta.getMaxRowSize());
-    assertEquals(0, meta.getMaxSchemaNameLength());
+    assertEquals(128, meta.getMaxSchemaNameLength());
     assertEquals(1000000, meta.getMaxStatementLength());
     assertEquals(0, meta.getMaxStatements());
     assertEquals(128, meta.getMaxTableNameLength());
@@ -245,11 +245,11 @@ public class JdbcDatabaseMetaDataTest {
     assertTrue(meta.supportsResultSetHoldability(ResultSet.CLOSE_CURSORS_AT_COMMIT));
     assertFalse(meta.supportsResultSetHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT));
     assertFalse(meta.supportsSavepoints());
-    assertFalse(meta.supportsSchemasInDataManipulation());
-    assertFalse(meta.supportsSchemasInIndexDefinitions());
-    assertFalse(meta.supportsSchemasInPrivilegeDefinitions());
-    assertFalse(meta.supportsSchemasInProcedureCalls());
-    assertFalse(meta.supportsSchemasInTableDefinitions());
+    assertTrue(meta.supportsSchemasInDataManipulation());
+    assertTrue(meta.supportsSchemasInIndexDefinitions());
+    assertTrue(meta.supportsSchemasInPrivilegeDefinitions());
+    assertTrue(meta.supportsSchemasInProcedureCalls());
+    assertTrue(meta.supportsSchemasInTableDefinitions());
     assertFalse(meta.supportsSelectForUpdate());
     assertFalse(meta.supportsStatementPooling());
     assertFalse(meta.supportsStoredFunctionsUsingCallSyntax());