Skip to content

Commit ca85276

Browse files
authored
chore: make DatabaseClient accessible in the Connection API (#1847)
Makes the underlying `DatabaseClient` accessible in the Connection API so this can be used by drivers that need direct access to it. See https://github.com/GoogleCloudPlatform/pgadapter/blob/8f0d47785e04dc9db6ee275074777849f006d797/src/main/java/com/google/cloud/spanner/pgadapter/utils/MutationWriter.java#L439
1 parent 40110fe commit ca85276

File tree

3 files changed

+17
-1
lines changed

3 files changed

+17
-1
lines changed

google-cloud-spanner/clirr-ignored-differences.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,14 @@
6060
<className>com/google/cloud/spanner/spi/v1/SpannerRpc</className>
6161
<method>com.google.api.gax.longrunning.OperationFuture copyBackup(com.google.cloud.spanner.BackupId, com.google.cloud.spanner.Backup)</method>
6262
</difference>
63+
<difference>
64+
<differenceType>7012</differenceType>
65+
<className>com/google/cloud/spanner/connection/Connection</className>
66+
<method>com.google.cloud.spanner.DatabaseClient getDatabaseClient()</method>
67+
</difference>
6368
<difference>
6469
<differenceType>7012</differenceType>
6570
<className>com/google/cloud/spanner/DatabaseAdminClient</className>
6671
<method>com.google.api.gax.longrunning.OperationFuture createDatabase(java.lang.String, java.lang.String, com.google.cloud.spanner.Dialect, java.lang.Iterable)</method>
6772
</difference>
68-
6973
</differences>

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/Connection.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.cloud.spanner.AbortedException;
2424
import com.google.cloud.spanner.AsyncResultSet;
2525
import com.google.cloud.spanner.CommitResponse;
26+
import com.google.cloud.spanner.DatabaseClient;
2627
import com.google.cloud.spanner.Dialect;
2728
import com.google.cloud.spanner.ErrorCode;
2829
import com.google.cloud.spanner.Mutation;
@@ -1104,6 +1105,12 @@ default Dialect getDialect() {
11041105
throw new UnsupportedOperationException("Not implemented");
11051106
}
11061107

1108+
/** The {@link DatabaseClient} that is used by this {@link Connection}. */
1109+
@InternalApi
1110+
default DatabaseClient getDatabaseClient() {
1111+
throw new UnsupportedOperationException("Not implemented");
1112+
}
1113+
11071114
/**
11081115
* This query option is used internally to indicate that a query is executed by the library itself
11091116
* to fetch metadata. These queries are specifically allowed to be executed even when a DDL batch

google-cloud-spanner/src/main/java/com/google/cloud/spanner/connection/ConnectionImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -332,6 +332,11 @@ public Dialect getDialect() {
332332
return dbClient.getDialect();
333333
}
334334

335+
@Override
336+
public DatabaseClient getDatabaseClient() {
337+
return dbClient;
338+
}
339+
335340
@Override
336341
public boolean isClosed() {
337342
return closed;

0 commit comments

Comments
 (0)