Skip to content
This repository was archived by the owner on Mar 26, 2026. It is now read-only.

Commit b57662f

Browse files
authored
deps: update dependency com.google.cloud:google-cloud-spanner-bom to v6.64.0 (#1565)
[![Mend Renovate](https://app.renovatebot.com/images/banner.svg)](https://renovatebot.com) This PR contains the following updates: | Package | Change | Age | Adoption | Passing | Confidence | |---|---|---|---|---|---| | [com.google.cloud:google-cloud-spanner-bom](https://togithub.com/googleapis/java-spanner) | `6.63.0` -> `6.64.0` | [![age](https://developer.mend.io/api/mc/badges/age/maven/com.google.cloud:google-cloud-spanner-bom/6.64.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![adoption](https://developer.mend.io/api/mc/badges/adoption/maven/com.google.cloud:google-cloud-spanner-bom/6.64.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![passing](https://developer.mend.io/api/mc/badges/compatibility/maven/com.google.cloud:google-cloud-spanner-bom/6.63.0/6.64.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | [![confidence](https://developer.mend.io/api/mc/badges/confidence/maven/com.google.cloud:google-cloud-spanner-bom/6.63.0/6.64.0?slim=true)](https://docs.renovatebot.com/merge-confidence/) | --- ### Release Notes <details> <summary>googleapis/java-spanner (com.google.cloud:google-cloud-spanner-bom)</summary> ### [`v6.64.0`](https://togithub.com/googleapis/java-spanner/blob/HEAD/CHANGELOG.md#6640-2024-04-12) [Compare Source](https://togithub.com/googleapis/java-spanner/compare/v6.63.0...v6.64.0) ##### Features - Add endpoint connection URL property ([#&#8203;2969](https://togithub.com/googleapis/java-spanner/issues/2969)) ([c9be29c](https://togithub.com/googleapis/java-spanner/commit/c9be29c717924d7f4c5acd8fe09ee371d0101642)) - Add PG OID support ([#&#8203;2736](https://togithub.com/googleapis/java-spanner/issues/2736)) ([ba2a4af](https://togithub.com/googleapis/java-spanner/commit/ba2a4afa5c1d64c932e9687d52b15c28d9dd7d91)) - Add SessionPoolOptions, SpannerOptions protos in executor protos ([#&#8203;2932](https://togithub.com/googleapis/java-spanner/issues/2932)) ([1673fd7](https://togithub.com/googleapis/java-spanner/commit/1673fd70df4ebfaa4b5fa07112d152119427699a)) - Support max_commit_delay in Connection API ([#&#8203;2954](https://togithub.com/googleapis/java-spanner/issues/2954)) ([a8f1852](https://togithub.com/googleapis/java-spanner/commit/a8f185261c812e7d6c92cb61ecc1f9c78ba3c4d9)) ##### Bug Fixes - Executor framework changes skipped in clirr checks, and added exception for partition methods in admin class ([#&#8203;3000](https://togithub.com/googleapis/java-spanner/issues/3000)) ([c2d8e95](https://togithub.com/googleapis/java-spanner/commit/c2d8e955abddb0117f1b3b94c2d9650d2cf4fdfd)) ##### Dependencies - Update actions/checkout action to v4 ([#&#8203;3006](https://togithub.com/googleapis/java-spanner/issues/3006)) ([368a9f3](https://togithub.com/googleapis/java-spanner/commit/368a9f33758961d8e3fd387ec94d380e7c6460cc)) - Update actions/github-script action to v7 ([#&#8203;3007](https://togithub.com/googleapis/java-spanner/issues/3007)) ([b0cfea6](https://togithub.com/googleapis/java-spanner/commit/b0cfea6e73b7293f564357e8d1c8c6bb2e0cf855)) - Update actions/setup-java action to v4 ([#&#8203;3008](https://togithub.com/googleapis/java-spanner/issues/3008)) ([d337080](https://togithub.com/googleapis/java-spanner/commit/d337080089dbd58cb4bf94f2cb5925f627435d39)) - Update dependency com.google.cloud:google-cloud-monitoring to v3.42.0 ([#&#8203;2997](https://togithub.com/googleapis/java-spanner/issues/2997)) ([0615beb](https://togithub.com/googleapis/java-spanner/commit/0615beb806ef62dbbfcc6bbffd082adc9c62372c)) - Update dependency com.google.cloud:google-cloud-trace to v2.41.0 ([#&#8203;2998](https://togithub.com/googleapis/java-spanner/issues/2998)) ([f50cd04](https://togithub.com/googleapis/java-spanner/commit/f50cd04660f480c62ddbd6c8a9e892cd95ec16b0)) - Update dependency commons-io:commons-io to v2.16.1 ([#&#8203;3020](https://togithub.com/googleapis/java-spanner/issues/3020)) ([aafd5b9](https://togithub.com/googleapis/java-spanner/commit/aafd5b9514c14a0dbfd0bf2616990f3c347ac0c6)) - Update opentelemetry.version to v1.37.0 ([#&#8203;3021](https://togithub.com/googleapis/java-spanner/issues/3021)) ([8f1ed2a](https://togithub.com/googleapis/java-spanner/commit/8f1ed2ac20896fb413749bb18652764096f1fb2d)) - Update stcarolas/setup-maven action to v5 ([#&#8203;3009](https://togithub.com/googleapis/java-spanner/issues/3009)) ([541acd2](https://togithub.com/googleapis/java-spanner/commit/541acd23aaf2c9336615406e30618fb65606e6c5)) </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://developer.mend.io/github/googleapis/java-spanner-jdbc). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNy4yOTMuMCIsInVwZGF0ZWRJblZlciI6IjM3LjI5My4wIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6W119-->
1 parent 2258ae3 commit b57662f

7 files changed

Lines changed: 93 additions & 29 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<dependency>
6363
<groupId>com.google.cloud</groupId>
6464
<artifactId>google-cloud-spanner-bom</artifactId>
65-
<version>6.63.0</version>
65+
<version>6.64.0</version>
6666
<type>pom</type>
6767
<scope>import</scope>
6868
</dependency>

src/main/java/com/google/cloud/spanner/jdbc/AbstractJdbcWrapper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.cloud.spanner.jdbc;
1818

19+
import static com.google.cloud.spanner.jdbc.JdbcTypeConverter.getMainTypeCode;
20+
1921
import com.google.cloud.spanner.Dialect;
2022
import com.google.cloud.spanner.Type;
2123
import com.google.cloud.spanner.Type.Code;
@@ -42,7 +44,7 @@ abstract class AbstractJdbcWrapper implements Wrapper {
4244
*/
4345
static int extractColumnType(Type type) {
4446
Preconditions.checkNotNull(type);
45-
switch (type.getCode()) {
47+
switch (getMainTypeCode(type)) {
4648
case BOOL:
4749
return Types.BOOLEAN;
4850
case BYTES:
@@ -139,7 +141,7 @@ static String getClassName(int sqlType) {
139141
*/
140142
static String getClassName(Type type) {
141143
Preconditions.checkNotNull(type);
142-
switch (type.getCode()) {
144+
switch (getMainTypeCode(type)) {
143145
case BOOL:
144146
return Boolean.class.getName();
145147
case BYTES:
@@ -162,7 +164,7 @@ static String getClassName(Type type) {
162164
case TIMESTAMP:
163165
return Timestamp.class.getName();
164166
case ARRAY:
165-
switch (type.getArrayElementType().getCode()) {
167+
switch (getMainTypeCode(type.getArrayElementType())) {
166168
case BOOL:
167169
return Boolean[].class.getName();
168170
case BYTES:

src/main/java/com/google/cloud/spanner/jdbc/JdbcResultSet.java

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
package com.google.cloud.spanner.jdbc;
1818

19+
import static com.google.cloud.spanner.jdbc.JdbcTypeConverter.getMainTypeCode;
20+
1921
import com.google.cloud.spanner.ResultSets;
2022
import com.google.cloud.spanner.Struct;
2123
import com.google.cloud.spanner.Type;
@@ -195,7 +197,7 @@ public String getString(int columnIndex) throws SQLException {
195197
checkClosedAndValidRow();
196198
boolean isNull = isNull(columnIndex);
197199
int spannerIndex = columnIndex - 1;
198-
Code type = spanner.getColumnType(spannerIndex).getCode();
200+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
199201
switch (type) {
200202
case BOOL:
201203
return isNull ? null : String.valueOf(spanner.getBoolean(spannerIndex));
@@ -233,7 +235,7 @@ public boolean getBoolean(int columnIndex) throws SQLException {
233235
checkClosedAndValidRow();
234236
boolean isNull = isNull(columnIndex);
235237
int spannerIndex = columnIndex - 1;
236-
Code type = spanner.getColumnType(spannerIndex).getCode();
238+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
237239
switch (type) {
238240
case BOOL:
239241
return !isNull && spanner.getBoolean(spannerIndex);
@@ -266,7 +268,7 @@ public byte getByte(int columnIndex) throws SQLException {
266268
checkClosedAndValidRow();
267269
boolean isNull = isNull(columnIndex);
268270
int spannerIndex = columnIndex - 1;
269-
Code type = spanner.getColumnType(spannerIndex).getCode();
271+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
270272
switch (type) {
271273
case BOOL:
272274
return isNull ? (byte) 0 : (spanner.getBoolean(spannerIndex) ? (byte) 1 : 0);
@@ -305,7 +307,7 @@ public short getShort(int columnIndex) throws SQLException {
305307
checkClosedAndValidRow();
306308
boolean isNull = isNull(columnIndex);
307309
int spannerIndex = columnIndex - 1;
308-
Code type = spanner.getColumnType(spannerIndex).getCode();
310+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
309311
switch (type) {
310312
case BOOL:
311313
return isNull ? 0 : (spanner.getBoolean(spannerIndex) ? (short) 1 : 0);
@@ -344,7 +346,7 @@ public int getInt(int columnIndex) throws SQLException {
344346
checkClosedAndValidRow();
345347
boolean isNull = isNull(columnIndex);
346348
int spannerIndex = columnIndex - 1;
347-
Code type = spanner.getColumnType(spannerIndex).getCode();
349+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
348350
switch (type) {
349351
case BOOL:
350352
return isNull ? 0 : (spanner.getBoolean(spannerIndex) ? 1 : 0);
@@ -383,7 +385,7 @@ public long getLong(int columnIndex) throws SQLException {
383385
checkClosedAndValidRow();
384386
boolean isNull = isNull(columnIndex);
385387
int spannerIndex = columnIndex - 1;
386-
Code type = spanner.getColumnType(spannerIndex).getCode();
388+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
387389
switch (type) {
388390
case BOOL:
389391
return isNull ? 0L : (spanner.getBoolean(spannerIndex) ? 1L : 0L);
@@ -418,7 +420,7 @@ public float getFloat(int columnIndex) throws SQLException {
418420
checkClosedAndValidRow();
419421
boolean isNull = isNull(columnIndex);
420422
int spannerIndex = columnIndex - 1;
421-
Code type = spanner.getColumnType(spannerIndex).getCode();
423+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
422424
switch (type) {
423425
case BOOL:
424426
return isNull ? 0 : (spanner.getBoolean(spannerIndex) ? (float) 1 : 0);
@@ -451,7 +453,7 @@ public double getDouble(int columnIndex) throws SQLException {
451453
checkClosedAndValidRow();
452454
boolean isNull = isNull(columnIndex);
453455
int spannerIndex = columnIndex - 1;
454-
Code type = spanner.getColumnType(spannerIndex).getCode();
456+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
455457
switch (type) {
456458
case BOOL:
457459
return isNull ? 0 : (spanner.getBoolean(spannerIndex) ? (double) 1 : 0);
@@ -492,7 +494,7 @@ public Date getDate(int columnIndex) throws SQLException {
492494
checkClosedAndValidRow();
493495
boolean isNull = isNull(columnIndex);
494496
int spannerIndex = columnIndex - 1;
495-
Code type = spanner.getColumnType(spannerIndex).getCode();
497+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
496498
switch (type) {
497499
case DATE:
498500
return isNull ? null : JdbcTypeConverter.toSqlDate(spanner.getDate(spannerIndex));
@@ -523,7 +525,7 @@ public Time getTime(int columnIndex) throws SQLException {
523525
checkClosedAndValidRow();
524526
boolean isNull = isNull(columnIndex);
525527
int spannerIndex = columnIndex - 1;
526-
Code type = spanner.getColumnType(spannerIndex).getCode();
528+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
527529
switch (type) {
528530
case STRING:
529531
return isNull ? null : parseTime(spanner.getString(spannerIndex));
@@ -551,7 +553,7 @@ public Timestamp getTimestamp(int columnIndex) throws SQLException {
551553
checkClosedAndValidRow();
552554
boolean isNull = isNull(columnIndex);
553555
int spannerIndex = columnIndex - 1;
554-
Code type = spanner.getColumnType(spannerIndex).getCode();
556+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
555557
switch (type) {
556558
case DATE:
557559
return isNull ? null : JdbcTypeConverter.toSqlTimestamp(spanner.getDate(spannerIndex));
@@ -716,14 +718,17 @@ public Object getObject(int columnIndex) throws SQLException {
716718
}
717719

718720
private Object getObject(Type type, int columnIndex) throws SQLException {
721+
// TODO: Refactor to check based on type code.
719722
if (type == Type.bool()) return getBoolean(columnIndex);
720723
if (type == Type.bytes()) return getBytes(columnIndex);
721724
if (type == Type.date()) return getDate(columnIndex);
722725
if (type == Type.float32()) {
723726
return getFloat(columnIndex);
724727
}
725728
if (type == Type.float64()) return getDouble(columnIndex);
726-
if (type == Type.int64()) return getLong(columnIndex);
729+
if (type == Type.int64() || type == Type.pgOid()) {
730+
return getLong(columnIndex);
731+
}
727732
if (type == Type.numeric()) return getBigDecimal(columnIndex);
728733
if (type == Type.pgNumeric()) {
729734
final String value = getString(columnIndex);
@@ -734,7 +739,9 @@ private Object getObject(Type type, int columnIndex) throws SQLException {
734739
}
735740
}
736741
if (type == Type.string()) return getString(columnIndex);
737-
if (type == Type.json()) return getString(columnIndex);
742+
if (type == Type.json() || type == Type.pgJsonb()) {
743+
return getString(columnIndex);
744+
}
738745
if (type == Type.timestamp()) return getTimestamp(columnIndex);
739746
if (type.getCode() == Code.ARRAY) return getArray(columnIndex);
740747
throw JdbcSqlExceptionFactory.of("Unknown type: " + type, com.google.rpc.Code.INVALID_ARGUMENT);
@@ -792,7 +799,7 @@ public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLExcepti
792799
private BigDecimal getBigDecimal(int columnIndex, boolean fixedScale, int scale)
793800
throws SQLException {
794801
int spannerIndex = columnIndex - 1;
795-
Code type = spanner.getColumnType(spannerIndex).getCode();
802+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
796803
boolean isNull = isNull(columnIndex);
797804
BigDecimal res;
798805
switch (type) {
@@ -888,7 +895,7 @@ public Array getArray(int columnIndex) throws SQLException {
888895
throw JdbcSqlExceptionFactory.of(
889896
"Column with index " + columnIndex + " does not contain an array",
890897
com.google.rpc.Code.INVALID_ARGUMENT);
891-
final Code elementCode = type.getArrayElementType().getCode();
898+
final Code elementCode = getMainTypeCode(type.getArrayElementType());
892899
final JdbcDataType dataType = JdbcDataType.getType(elementCode);
893900
try {
894901
List<?> elements = dataType.getArrayElements(spanner, columnIndex - 1);
@@ -907,7 +914,7 @@ public Date getDate(int columnIndex, Calendar cal) throws SQLException {
907914
return null;
908915
}
909916
int spannerIndex = columnIndex - 1;
910-
Code type = spanner.getColumnType(spannerIndex).getCode();
917+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
911918
switch (type) {
912919
case DATE:
913920
return JdbcTypeConverter.toSqlDate(spanner.getDate(spannerIndex), cal);
@@ -941,7 +948,7 @@ public Time getTime(int columnIndex, Calendar cal) throws SQLException {
941948
checkClosedAndValidRow();
942949
boolean isNull = isNull(columnIndex);
943950
int spannerIndex = columnIndex - 1;
944-
Code type = spanner.getColumnType(spannerIndex).getCode();
951+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
945952
switch (type) {
946953
case STRING:
947954
return isNull ? null : parseTime(spanner.getString(spannerIndex), cal);
@@ -975,7 +982,7 @@ public Timestamp getTimestamp(int columnIndex, Calendar cal) throws SQLException
975982
return null;
976983
}
977984
int spannerIndex = columnIndex - 1;
978-
Code type = spanner.getColumnType(spannerIndex).getCode();
985+
Code type = getMainTypeCode(spanner.getColumnType(spannerIndex));
979986
switch (type) {
980987
case DATE:
981988
return JdbcTypeConverter.toSqlTimestamp(spanner.getDate(spannerIndex), cal);

src/main/java/com/google/cloud/spanner/jdbc/JdbcTypeConverter.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import com.google.cloud.spanner.Type;
2323
import com.google.cloud.spanner.Type.Code;
2424
import com.google.cloud.spanner.Value;
25+
import com.google.common.base.Preconditions;
2526
import java.math.BigDecimal;
2627
import java.math.BigInteger;
2728
import java.nio.charset.Charset;
@@ -46,6 +47,17 @@ class JdbcTypeConverter {
4647
private static final DateTimeFormatter TIMESTAMP_FORMAT = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
4748
private static final Charset UTF8 = StandardCharsets.UTF_8;
4849

50+
// TODO: Remove when this is supported in the Java client library.
51+
static Code getMainTypeCode(Type type) {
52+
Preconditions.checkNotNull(type);
53+
switch (type.getCode()) {
54+
case PG_OID:
55+
return Code.INT64;
56+
default:
57+
return type.getCode();
58+
}
59+
}
60+
4961
/**
5062
* Converts the given value from the Google {@link Type} to the Java {@link Class} type. The input
5163
* value and the {@link Type} must be consistent with each other.
@@ -205,6 +217,8 @@ private static Value convertToSpannerValue(Object value, Type type) throws SQLEx
205217
Arrays.asList((Double[]) ((java.sql.Array) value).getArray()));
206218
case INT64:
207219
return Value.int64Array(Arrays.asList((Long[]) ((java.sql.Array) value).getArray()));
220+
case PG_OID:
221+
return Value.pgOidArray(Arrays.asList((Long[]) ((java.sql.Array) value).getArray()));
208222
case NUMERIC:
209223
return Value.numericArray(
210224
Arrays.asList((BigDecimal[]) ((java.sql.Array) value).getArray()));
@@ -238,6 +252,8 @@ private static Value convertToSpannerValue(Object value, Type type) throws SQLEx
238252
return Value.float64((Double) value);
239253
case INT64:
240254
return Value.int64((Long) value);
255+
case PG_OID:
256+
return Value.pgOid((Long) value);
241257
case NUMERIC:
242258
return Value.numeric((BigDecimal) value);
243259
case PG_NUMERIC:

src/test/java/com/google/cloud/spanner/jdbc/AllTypesMockServerTest.java

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,9 @@ public void testSelectAllTypes() {
7575
DATE_VALUE.getYear() - 1900, DATE_VALUE.getMonth() - 1, DATE_VALUE.getDayOfMonth()),
7676
resultSet.getDate(++col));
7777
assertEquals(TIMESTAMP_VALUE.toSqlTimestamp(), resultSet.getTimestamp(++col));
78+
if (dialect == Dialect.POSTGRESQL) {
79+
assertEquals(PG_OID_VALUE, resultSet.getLong(++col));
80+
}
7881

7982
assertEquals(
8083
BOOL_ARRAY_VALUE, Arrays.asList((Boolean[]) resultSet.getArray(++col).getArray()));
@@ -122,6 +125,10 @@ public void testSelectAllTypes() {
122125
.map(timestamp -> timestamp == null ? null : timestamp.toSqlTimestamp())
123126
.collect(Collectors.toList()),
124127
Arrays.asList((Timestamp[]) resultSet.getArray(++col).getArray()));
128+
if (dialect == Dialect.POSTGRESQL) {
129+
assertEquals(
130+
PG_OID_ARRAY_VALUE, Arrays.asList((Long[]) resultSet.getArray(++col).getArray()));
131+
}
125132

126133
assertFalse(resultSet.next());
127134
}
@@ -140,7 +147,7 @@ public void testInsertAllTypes() {
140147
insertStatement
141148
.toBuilder()
142149
.replace(insertStatement.getSql().replaceAll("@p", "\\$"))
143-
.bind("p15")
150+
.bind("p16")
144151
.to(
145152
com.google.cloud.spanner.Value.pgNumericArray(
146153
NUMERIC_ARRAY_VALUE.stream()
@@ -179,6 +186,9 @@ public void testInsertAllTypes() {
179186
DATE_VALUE.getMonth() - 1,
180187
DATE_VALUE.getDayOfMonth()));
181188
statement.setTimestamp(++param, TIMESTAMP_VALUE.toSqlTimestamp());
189+
if (dialect == Dialect.POSTGRESQL) {
190+
statement.setLong(++param, PG_OID_VALUE);
191+
}
182192

183193
// TODO: Support PostgreSQL type names for creating arrays.
184194
statement.setArray(
@@ -241,6 +251,10 @@ public void testInsertAllTypes() {
241251
TIMESTAMP_ARRAY_VALUE.stream()
242252
.map(timestamp -> timestamp == null ? null : timestamp.toSqlTimestamp())
243253
.toArray(Timestamp[]::new)));
254+
if (dialect == Dialect.POSTGRESQL) {
255+
statement.setArray(
256+
++param, connection.createArrayOf("INT64", PG_OID_ARRAY_VALUE.toArray(new Long[0])));
257+
}
244258

245259
assertEquals(1, statement.executeUpdate());
246260
}
@@ -249,8 +263,8 @@ public void testInsertAllTypes() {
249263
ExecuteSqlRequest request = mockSpanner.getRequestsOfType(ExecuteSqlRequest.class).get(0);
250264
Map<String, Type> paramTypes = request.getParamTypesMap();
251265
Map<String, Value> params = request.getParams().getFieldsMap();
252-
assertEquals(20, paramTypes.size());
253-
assertEquals(20, params.size());
266+
assertEquals(dialect == Dialect.POSTGRESQL ? 22 : 20, paramTypes.size());
267+
assertEquals(dialect == Dialect.POSTGRESQL ? 22 : 20, params.size());
254268

255269
// Verify param types.
256270
ImmutableList<TypeCode> expectedTypes =
@@ -265,6 +279,10 @@ public void testInsertAllTypes() {
265279
TypeCode.BYTES,
266280
TypeCode.DATE,
267281
TypeCode.TIMESTAMP);
282+
if (dialect == Dialect.POSTGRESQL) {
283+
expectedTypes =
284+
ImmutableList.<TypeCode>builder().addAll(expectedTypes).add(TypeCode.INT64).build();
285+
}
268286
for (int col = 0; col < expectedTypes.size(); col++) {
269287
assertEquals(expectedTypes.get(col), paramTypes.get("p" + (col + 1)).getCode());
270288
int arrayCol = col + expectedTypes.size();
@@ -290,6 +308,9 @@ public void testInsertAllTypes() {
290308
params.get("p" + ++col).getStringValue());
291309
assertEquals(DATE_VALUE.toString(), params.get("p" + ++col).getStringValue());
292310
assertEquals(TIMESTAMP_VALUE.toString(), params.get("p" + ++col).getStringValue());
311+
if (dialect == Dialect.POSTGRESQL) {
312+
assertEquals(String.valueOf(PG_OID_VALUE), params.get("p" + ++col).getStringValue());
313+
}
293314

294315
assertEquals(
295316
BOOL_ARRAY_VALUE,
@@ -365,6 +386,13 @@ public void testInsertAllTypes() {
365386
? null
366387
: com.google.cloud.Timestamp.parseTimestamp(value.getStringValue()))
367388
.collect(Collectors.toList()));
389+
if (dialect == Dialect.POSTGRESQL) {
390+
assertEquals(
391+
PG_OID_ARRAY_VALUE,
392+
params.get("p" + ++col).getListValue().getValuesList().stream()
393+
.map(value -> value.hasNullValue() ? null : Long.valueOf(value.getStringValue()))
394+
.collect(Collectors.toList()));
395+
}
368396
} catch (SQLException sqlException) {
369397
throw new RuntimeException(sqlException);
370398
}

src/test/java/com/google/cloud/spanner/jdbc/PartitionedQueryMockServerTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ public void clearRequests() {
7373

7474
private int getExpectedColumnCount(Dialect dialect) {
7575
// GoogleSQL also adds 4 PROTO columns.
76-
return dialect == Dialect.GOOGLE_STANDARD_SQL ? 24 : 20;
76+
// PostgreSQL adds 2 OID columns.
77+
return dialect == Dialect.GOOGLE_STANDARD_SQL ? 24 : 22;
7778
}
7879

7980
private String createUrl() {

0 commit comments

Comments
 (0)