From 45f44853c8ab58abb220cde3f2f0767e64aea4fb Mon Sep 17 00:00:00 2001 From: Quynh Tran Date: Tue, 21 Nov 2023 10:36:07 +1100 Subject: [PATCH] chore: fix lint errors --- .../java/com/google/cloud/spanner/Value.java | 10 +- .../AbstractStructReaderTypesTest.java | 8 +- .../cloud/spanner/DatabaseClientImplTest.java | 418 +++++++++--------- .../cloud/spanner/GrpcResultSetTest.java | 10 +- .../google/cloud/spanner/MutationTest.java | 2 +- .../google/cloud/spanner/ValueBinderTest.java | 2 +- .../com/google/cloud/spanner/ValueTest.java | 14 +- .../connection/RandomResultSetGenerator.java | 158 +++---- .../google/cloud/spanner/it/ITQueryTest.java | 8 +- 9 files changed, 314 insertions(+), 316 deletions(-) diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java index 21b77e00934..bf0b1326df0 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/Value.java @@ -231,7 +231,7 @@ public static Value pgJsonb(@Nullable String v) { return new PgJsonbImpl(v == null, v); } - /** + /** * Returns an {@code PG_OID} value. * * @param v the value, which may be null @@ -925,7 +925,7 @@ Value newValue(boolean isNull, BitSet nulls, long[] values) { return new PgOidArrayImpl(isNull, nulls, values); } }; - + private static final PrimitiveArrayValueFactory float64ArrayFactory = new PrimitiveArrayValueFactory() { @Override @@ -2087,8 +2087,8 @@ Long getValue(int i) { @Override com.google.protobuf.Value getValueAsProto(int i) { return com.google.protobuf.Value.newBuilder() - .setStringValue(Long.toString(values[i])) - .build(); + .setStringValue(Long.toString(values[i])) + .build(); } @Override @@ -2335,7 +2335,7 @@ private Value getValue(int fieldIndex) { return Value.jsonArray(value.getJsonList(fieldIndex)); case PG_JSONB: return Value.pgJsonbArray(value.getPgJsonbList(fieldIndex)); - case PG_OID: + case PG_OID: return Value.pgOidArray(value.getPgOidList(fieldIndex)); case BYTES: return Value.bytesArray(value.getBytesList(fieldIndex)); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractStructReaderTypesTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractStructReaderTypesTest.java index 026b4ac5a24..9bf12160156 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractStructReaderTypesTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/AbstractStructReaderTypesTest.java @@ -253,7 +253,13 @@ public static Collection parameters() { "getJson", Collections.singletonList("getValue") }, - {Type.pgOid(), "getPgOidInternal", 123L, "getPgOid", Collections.singletonList("getValue")}, + { + Type.pgOid(), + "getPgOidInternal", + 123L, + "getPgOid", + Collections.singletonList("getValue") + }, { Type.timestamp(), "getTimestampInternal", diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java index 23308c0419e..5fee6cfc346 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/DatabaseClientImplTest.java @@ -3638,225 +3638,209 @@ public void testByteArray() { public void testGetAllTypesAsString() { for (Dialect dialect : Dialect.values()) { Statement statement = Statement.of("select * from all_types"); - ListValue.Builder dialectBasedBuilder = ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder().setBoolValue(true).build()) - .addValues( - com.google.protobuf.Value.newBuilder().setStringValue("100").build()) - .addValues( - com.google.protobuf.Value.newBuilder().setNumberValue(3.14d).build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("6.626") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("test-string") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("{\"key1\": \"value1\"}") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue( - Base64.getEncoder() - .encodeToString( - "test-bytes".getBytes(StandardCharsets.UTF_8))) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("2023-01-11") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("2023-01-11T11:55:18.123456789Z") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setBoolValue(true) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setBoolValue(false) - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue(String.valueOf(Long.MAX_VALUE)) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue(String.valueOf(Long.MIN_VALUE)) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNumberValue(-12345.6789d) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNumberValue(3.14d) - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("6.626") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("-8.9123") - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("test-string1") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("test-string2") - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("{\"key\": \"value1\"}") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("{\"key\": \"value2\"}") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue( - Base64.getEncoder() - .encodeToString( - "test-bytes1" - .getBytes( - StandardCharsets.UTF_8))) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue( - Base64.getEncoder() - .encodeToString( - "test-bytes2" - .getBytes( - StandardCharsets.UTF_8))) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("2000-02-29") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("2000-01-01") - .build()) - .build())) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("2023-01-11T11:55:18.123456789Z") - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue("2023-01-12T11:55:18Z") - .build()) - .build())); + ListValue.Builder dialectBasedBuilder = + ListValue.newBuilder() + .addValues(com.google.protobuf.Value.newBuilder().setBoolValue(true).build()) + .addValues(com.google.protobuf.Value.newBuilder().setStringValue("100").build()) + .addValues(com.google.protobuf.Value.newBuilder().setNumberValue(3.14d).build()) + .addValues(com.google.protobuf.Value.newBuilder().setStringValue("6.626").build()) + .addValues( + com.google.protobuf.Value.newBuilder().setStringValue("test-string").build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("{\"key1\": \"value1\"}") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue( + Base64.getEncoder() + .encodeToString("test-bytes".getBytes(StandardCharsets.UTF_8))) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder().setStringValue("2023-01-11").build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("2023-01-11T11:55:18.123456789Z") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder().setBoolValue(true).build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setBoolValue(false) + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue(String.valueOf(Long.MAX_VALUE)) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue(String.valueOf(Long.MIN_VALUE)) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNumberValue(-12345.6789d) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNumberValue(3.14d) + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("6.626") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("-8.9123") + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("test-string1") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("test-string2") + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("{\"key\": \"value1\"}") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("{\"key\": \"value2\"}") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue( + Base64.getEncoder() + .encodeToString( + "test-bytes1".getBytes(StandardCharsets.UTF_8))) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue( + Base64.getEncoder() + .encodeToString( + "test-bytes2".getBytes(StandardCharsets.UTF_8))) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("2000-02-29") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("2000-01-01") + .build()) + .build())) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("2023-01-11T11:55:18.123456789Z") + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue("2023-01-12T11:55:18Z") + .build()) + .build())); if (dialect == Dialect.POSTGRESQL) { - dialectBasedBuilder = dialectBasedBuilder - .addValues( - com.google.protobuf.Value.newBuilder().setStringValue("100").build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setListValue( - ListValue.newBuilder() - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue(String.valueOf(Long.MAX_VALUE)) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setStringValue(String.valueOf(Long.MIN_VALUE)) - .build()) - .addValues( - com.google.protobuf.Value.newBuilder() - .setNullValue(NullValue.NULL_VALUE) - .build()) - .build())); + dialectBasedBuilder = + dialectBasedBuilder + .addValues(com.google.protobuf.Value.newBuilder().setStringValue("100").build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setListValue( + ListValue.newBuilder() + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue(String.valueOf(Long.MAX_VALUE)) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setStringValue(String.valueOf(Long.MIN_VALUE)) + .build()) + .addValues( + com.google.protobuf.Value.newBuilder() + .setNullValue(NullValue.NULL_VALUE) + .build()) + .build())); } mockSpanner.putStatementResult( diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java index dc458a83262..c0a66652990 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/GrpcResultSetTest.java @@ -768,11 +768,11 @@ public void getPgJsonb() { @Test public void getPgOid() { consumer.onPartialResultSet( - PartialResultSet.newBuilder() - .setMetadata(makeMetadata(Type.struct(Type.StructField.of("f", Type.pgOid())))) - .addValues(Value.pgOid(Long.MIN_VALUE).toProto()) - .addValues(Value.pgOid(Long.MAX_VALUE).toProto()) - .build()); + PartialResultSet.newBuilder() + .setMetadata(makeMetadata(Type.struct(Type.StructField.of("f", Type.pgOid())))) + .addValues(Value.pgOid(Long.MIN_VALUE).toProto()) + .addValues(Value.pgOid(Long.MAX_VALUE).toProto()) + .build()); consumer.onCompleted(); assertThat(resultSet.next()).isTrue(); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MutationTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MutationTest.java index e14815c268d..cec9287b3a7 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MutationTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/MutationTest.java @@ -618,7 +618,7 @@ private Mutation.WriteBuilder appendAllTypes(Mutation.WriteBuilder builder) { .set("pgOidArrNull") .toPgOidArray((long[]) null) .set("pgOidArrValue") - .to(Value.pgOidArray(ImmutableList.of(1L, 2L))) + .to(Value.pgOidArray(ImmutableList.of(1L, 2L))) .set("timestampArr") .toTimestampArray(ImmutableList.of(Timestamp.MAX_VALUE, Timestamp.MAX_VALUE)) .set("timestampArrNull") diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueBinderTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueBinderTest.java index 79e94f8e249..47167bbaeae 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueBinderTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueBinderTest.java @@ -18,8 +18,8 @@ import static com.google.cloud.spanner.ValueBinderTest.DefaultValues.defaultBytesBase64; import static com.google.cloud.spanner.ValueBinderTest.DefaultValues.defaultJson; -import static com.google.cloud.spanner.ValueBinderTest.DefaultValues.defaultPgJsonb; import static com.google.cloud.spanner.ValueBinderTest.DefaultValues.defaultLongWrapper; +import static com.google.cloud.spanner.ValueBinderTest.DefaultValues.defaultPgJsonb; import static com.google.common.truth.Truth.assertThat; import static com.google.common.truth.Truth.assertWithMessage; diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueTest.java index ef56cb4fbce..03330a71326 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/ValueTest.java @@ -1929,10 +1929,10 @@ public void testEqualsHashCode() { tester.addEqualityGroup(Value.pgNumericArray(null), Value.pgNumericArray(null)); tester.addEqualityGroup( - Value.pgOidArray(Arrays.asList(1L, 2L)), - Value.pgOidArray(new long[] {1L, 2L}), - Value.pgOidArray(new long[] {0L, 1L, 2L, 3L}, 1, 2), - Value.pgOidArray(plainIterable(1L, 2L))); + Value.pgOidArray(Arrays.asList(1L, 2L)), + Value.pgOidArray(new long[] {1L, 2L}), + Value.pgOidArray(new long[] {0L, 1L, 2L, 3L}, 1, 2), + Value.pgOidArray(plainIterable(1L, 2L))); tester.addEqualityGroup(Value.pgOidArray(Collections.singletonList(3L))); tester.addEqualityGroup(Value.pgOidArray(Collections.singletonList(null))); tester.addEqualityGroup(Value.pgOidArray((Iterable) null)); @@ -2093,8 +2093,10 @@ public void serialization() { Value.pgNumericArray(BrokenSerializationList.of("1.23", "1.24", Value.NAN))); reserializeAndAssert(Value.pgNumericArray(null)); - reserializeAndAssert(Value.pgOidArray(BrokenSerializationList.of(Long.valueOf(1L), Long.valueOf(2L)))); - reserializeAndAssert(Value.pgOidArray(BrokenSerializationList.of(Long.valueOf(1L), Long.valueOf(2L), null))); + reserializeAndAssert( + Value.pgOidArray(BrokenSerializationList.of(Long.valueOf(1L), Long.valueOf(2L)))); + reserializeAndAssert( + Value.pgOidArray(BrokenSerializationList.of(Long.valueOf(1L), Long.valueOf(2L), null))); reserializeAndAssert(Value.pgOidArray((Iterable) null)); reserializeAndAssert(Value.timestamp(null)); diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/RandomResultSetGenerator.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/RandomResultSetGenerator.java index 77bad9d4360..f5eb90b8f36 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/RandomResultSetGenerator.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/connection/RandomResultSetGenerator.java @@ -44,85 +44,87 @@ public class RandomResultSetGenerator { public static Type[] generateAllTypes(Dialect dialect) { List allTypes = new ArrayList<>(); - allTypes.addAll(Arrays.asList( - Type.newBuilder().setCode(TypeCode.BOOL).build(), - Type.newBuilder().setCode(TypeCode.INT64).build(), - Type.newBuilder().setCode(TypeCode.FLOAT64).build(), - dialect == Dialect.POSTGRESQL - ? Type.newBuilder() - .setCode(TypeCode.NUMERIC) - .setTypeAnnotation(TypeAnnotationCode.PG_NUMERIC) - .build() - : Type.newBuilder().setCode(TypeCode.NUMERIC).build(), - Type.newBuilder().setCode(TypeCode.STRING).build(), - dialect == Dialect.POSTGRESQL - ? Type.newBuilder() - .setCode(TypeCode.JSON) - .setTypeAnnotation(TypeAnnotationCode.PG_JSONB) - .build() - : Type.newBuilder().setCode(TypeCode.JSON).build(), - Type.newBuilder().setCode(TypeCode.BYTES).build(), - Type.newBuilder().setCode(TypeCode.DATE).build(), - Type.newBuilder().setCode(TypeCode.TIMESTAMP).build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.BOOL)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.INT64)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.FLOAT64)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType( - dialect == Dialect.POSTGRESQL - ? Type.newBuilder() - .setCode(TypeCode.NUMERIC) - .setTypeAnnotation(TypeAnnotationCode.PG_NUMERIC) - : Type.newBuilder().setCode(TypeCode.NUMERIC)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.STRING)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType( - dialect == Dialect.POSTGRESQL - ? Type.newBuilder() - .setCode(TypeCode.JSON) - .setTypeAnnotation(TypeAnnotationCode.PG_JSONB) - : Type.newBuilder().setCode(TypeCode.JSON)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.BYTES)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.DATE)) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType(Type.newBuilder().setCode(TypeCode.TIMESTAMP)) - .build())); + allTypes.addAll( + Arrays.asList( + Type.newBuilder().setCode(TypeCode.BOOL).build(), + Type.newBuilder().setCode(TypeCode.INT64).build(), + Type.newBuilder().setCode(TypeCode.FLOAT64).build(), + dialect == Dialect.POSTGRESQL + ? Type.newBuilder() + .setCode(TypeCode.NUMERIC) + .setTypeAnnotation(TypeAnnotationCode.PG_NUMERIC) + .build() + : Type.newBuilder().setCode(TypeCode.NUMERIC).build(), + Type.newBuilder().setCode(TypeCode.STRING).build(), + dialect == Dialect.POSTGRESQL + ? Type.newBuilder() + .setCode(TypeCode.JSON) + .setTypeAnnotation(TypeAnnotationCode.PG_JSONB) + .build() + : Type.newBuilder().setCode(TypeCode.JSON).build(), + Type.newBuilder().setCode(TypeCode.BYTES).build(), + Type.newBuilder().setCode(TypeCode.DATE).build(), + Type.newBuilder().setCode(TypeCode.TIMESTAMP).build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.BOOL)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.INT64)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.FLOAT64)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType( + dialect == Dialect.POSTGRESQL + ? Type.newBuilder() + .setCode(TypeCode.NUMERIC) + .setTypeAnnotation(TypeAnnotationCode.PG_NUMERIC) + : Type.newBuilder().setCode(TypeCode.NUMERIC)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.STRING)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType( + dialect == Dialect.POSTGRESQL + ? Type.newBuilder() + .setCode(TypeCode.JSON) + .setTypeAnnotation(TypeAnnotationCode.PG_JSONB) + : Type.newBuilder().setCode(TypeCode.JSON)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.BYTES)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.DATE)) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType(Type.newBuilder().setCode(TypeCode.TIMESTAMP)) + .build())); if (dialect == Dialect.POSTGRESQL) { - allTypes.addAll(Arrays.asList( - Type.newBuilder() - .setCode(TypeCode.INT64) - .setTypeAnnotation(TypeAnnotationCode.PG_OID) - .build(), - Type.newBuilder() - .setCode(TypeCode.ARRAY) - .setArrayElementType( - Type.newBuilder() - .setCode(TypeCode.INT64) - .setTypeAnnotation(TypeAnnotationCode.PG_OID)) - .build())); + allTypes.addAll( + Arrays.asList( + Type.newBuilder() + .setCode(TypeCode.INT64) + .setTypeAnnotation(TypeAnnotationCode.PG_OID) + .build(), + Type.newBuilder() + .setCode(TypeCode.ARRAY) + .setArrayElementType( + Type.newBuilder() + .setCode(TypeCode.INT64) + .setTypeAnnotation(TypeAnnotationCode.PG_OID)) + .build())); } return allTypes.toArray(new Type[0]); } diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java index 2d0bcfa5cd6..4603ec5b6c5 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITQueryTest.java @@ -256,14 +256,18 @@ public void bindInt64Null() { @Test public void bindPgOid() { - Struct row = execute(Statement.newBuilder(selectValueQuery).bind("p1").to(Value.pgOid(1234)), Type.pgOid()); + Struct row = + execute( + Statement.newBuilder(selectValueQuery).bind("p1").to(Value.pgOid(1234)), Type.pgOid()); assertThat(row.isNull(0)).isFalse(); assertThat(row.getPgOid(0)).isEqualTo(1234); } @Test public void bindPgOidNull() { - Struct row = execute(Statement.newBuilder(selectValueQuery).bind("p1").to(Value.pgOid(null)), Type.pgOid()); + Struct row = + execute( + Statement.newBuilder(selectValueQuery).bind("p1").to(Value.pgOid(null)), Type.pgOid()); assertThat(row.isNull(0)).isTrue(); }