Skip to content

Commit 30123ad

Browse files
committed
Merge branch 'main' into PR #2113 to update
2 parents fd26243 + 7b30099 commit 30123ad

File tree

11 files changed

+66
-19
lines changed

11 files changed

+66
-19
lines changed

pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@
166166
<dependency>
167167
<groupId>org.testcontainers</groupId>
168168
<artifactId>testcontainers</artifactId>
169-
<version>1.21.3</version>
169+
<version>2.0.1</version>
170170
<scope>test</scope>
171171
</dependency>
172172
<dependency>
@@ -222,7 +222,7 @@
222222
<dependency>
223223
<groupId>com.google.api.grpc</groupId>
224224
<artifactId>proto-google-cloud-trace-v1</artifactId>
225-
<version>2.76.0</version>
225+
<version>2.78.0</version>
226226
<scope>test</scope>
227227
</dependency>
228228

samples/install-without-bom/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<dependency>
3030
<groupId>com.google.cloud</groupId>
3131
<artifactId>google-cloud-spanner-jdbc</artifactId>
32-
<version>2.33.0</version>
32+
<version>2.33.1</version>
3333
</dependency>
3434
<!-- [END spanner-jdbc_install_without_bom] -->
3535

samples/quickperf/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<dependency>
2828
<groupId>com.google.cloud</groupId>
2929
<artifactId>libraries-bom</artifactId>
30-
<version>26.69.0</version>
30+
<version>26.70.0</version>
3131
<type>pom</type>
3232
<scope>import</scope>
3333
</dependency>
@@ -73,7 +73,7 @@
7373
<dependency>
7474
<groupId>org.testcontainers</groupId>
7575
<artifactId>testcontainers</artifactId>
76-
<version>1.21.3</version>
76+
<version>2.0.1</version>
7777
<scope>test</scope>
7878
</dependency>
7979
<dependency>

samples/snippets/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
<dependency>
2727
<groupId>com.google.cloud</groupId>
2828
<artifactId>libraries-bom</artifactId>
29-
<version>26.69.0</version>
29+
<version>26.70.0</version>
3030
<type>pom</type>
3131
<scope>import</scope>
3232
</dependency>
@@ -54,7 +54,7 @@
5454
<dependency>
5555
<groupId>org.testcontainers</groupId>
5656
<artifactId>testcontainers</artifactId>
57-
<version>1.21.3</version>
57+
<version>2.0.1</version>
5858
<scope>test</scope>
5959
</dependency>
6060
<dependency>

samples/spring-data-jdbc/googlesql/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
<dependency>
3838
<groupId>com.google.cloud</groupId>
3939
<artifactId>libraries-bom</artifactId>
40-
<version>26.69.0</version>
40+
<version>26.70.0</version>
4141
<scope>import</scope>
4242
<type>pom</type>
4343
</dependency>
4444
<dependency>
4545
<groupId>io.opentelemetry</groupId>
4646
<artifactId>opentelemetry-bom</artifactId>
47-
<version>1.54.1</version>
47+
<version>1.55.0</version>
4848
<type>pom</type>
4949
<scope>import</scope>
5050
</dependency>
@@ -90,7 +90,7 @@
9090
<dependency>
9191
<groupId>org.testcontainers</groupId>
9292
<artifactId>testcontainers</artifactId>
93-
<version>1.21.3</version>
93+
<version>2.0.1</version>
9494
</dependency>
9595

9696
<dependency>

samples/spring-data-jdbc/postgresql/pom.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,14 @@
3737
<dependency>
3838
<groupId>com.google.cloud</groupId>
3939
<artifactId>libraries-bom</artifactId>
40-
<version>26.69.0</version>
40+
<version>26.70.0</version>
4141
<scope>import</scope>
4242
<type>pom</type>
4343
</dependency>
4444
<dependency>
4545
<groupId>io.opentelemetry</groupId>
4646
<artifactId>opentelemetry-bom</artifactId>
47-
<version>1.54.1</version>
47+
<version>1.55.0</version>
4848
<type>pom</type>
4949
<scope>import</scope>
5050
</dependency>
@@ -132,7 +132,7 @@
132132
<dependency>
133133
<groupId>org.testcontainers</groupId>
134134
<artifactId>testcontainers</artifactId>
135-
<version>1.21.3</version>
135+
<version>2.0.1</version>
136136
<scope>test</scope>
137137
</dependency>
138138
</dependencies>

samples/spring-data-mybatis/googlesql/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
<dependency>
4343
<groupId>com.google.cloud</groupId>
4444
<artifactId>libraries-bom</artifactId>
45-
<version>26.69.0</version>
45+
<version>26.70.0</version>
4646
<scope>import</scope>
4747
<type>pom</type>
4848
</dependency>

samples/spring-data-mybatis/postgresql/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
<dependency>
3636
<groupId>com.google.cloud</groupId>
3737
<artifactId>libraries-bom</artifactId>
38-
<version>26.69.0</version>
38+
<version>26.70.0</version>
3939
<scope>import</scope>
4040
<type>pom</type>
4141
</dependency>

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,11 @@ class JdbcArray implements Array {
6060
* the elements array is not compatible with the base type of the array.
6161
*/
6262
static JdbcArray createArray(String typeName, Object[] elements) throws SQLException {
63-
for (JdbcDataType type : JdbcDataType.values()) {
64-
if (type.getTypeName().equalsIgnoreCase(typeName)) {
65-
return new JdbcArray(type, elements);
63+
if (typeName != null) {
64+
for (JdbcDataType type : JdbcDataType.values()) {
65+
if (type.matches(typeName)) {
66+
return new JdbcArray(type, elements);
67+
}
6668
}
6769
}
6870
throw JdbcSqlExceptionFactory.of(

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

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

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

19+
import com.google.cloud.spanner.Dialect;
1920
import com.google.cloud.spanner.ResultSet;
2021
import com.google.cloud.spanner.Struct;
2122
import com.google.cloud.spanner.Type;
@@ -154,6 +155,7 @@ public Type getSpannerType() {
154155
},
155156
FLOAT64 {
156157
private final Set<Class<?>> classes = new HashSet<>(Arrays.asList(Float.class, Double.class));
158+
private final Set<String> aliases = new HashSet<>(Collections.singletonList("float8"));
157159

158160
@Override
159161
public int getSqlType() {
@@ -184,6 +186,11 @@ public List<Double> getArrayElements(ResultSet rs, int columnIndex) {
184186
public Type getSpannerType() {
185187
return Type.float64();
186188
}
189+
190+
@Override
191+
public Set<String> getPostgreSQLAliases() {
192+
return aliases;
193+
}
187194
},
188195
INT64 {
189196
private final Set<Class<?>> classes =
@@ -220,6 +227,9 @@ public Type getSpannerType() {
220227
}
221228
},
222229
NUMERIC {
230+
231+
private final Set<String> aliases = new HashSet<>(Collections.singletonList("decimal"));
232+
223233
@Override
224234
public int getSqlType() {
225235
return Types.NUMERIC;
@@ -244,6 +254,11 @@ public List<BigDecimal> getArrayElements(ResultSet rs, int columnIndex) {
244254
public Type getSpannerType() {
245255
return Type.numeric();
246256
}
257+
258+
@Override
259+
public Set<String> getPostgreSQLAliases() {
260+
return aliases;
261+
}
247262
},
248263
PG_NUMERIC {
249264
@Override
@@ -272,6 +287,8 @@ public Type getSpannerType() {
272287
}
273288
},
274289
STRING {
290+
private final Set<String> aliases = new HashSet<>(Arrays.asList("varchar", "text"));
291+
275292
@Override
276293
public int getSqlType() {
277294
return Types.NVARCHAR;
@@ -296,6 +313,11 @@ public List<String> getArrayElements(ResultSet rs, int columnIndex) {
296313
public Type getSpannerType() {
297314
return Type.string();
298315
}
316+
317+
@Override
318+
public Set<String> getPostgreSQLAliases() {
319+
return aliases;
320+
}
299321
},
300322
JSON {
301323
@Override
@@ -498,6 +520,21 @@ public Type getSpannerType() {
498520

499521
public abstract Type getSpannerType();
500522

523+
public Set<String> getPostgreSQLAliases() {
524+
return Collections.emptySet();
525+
}
526+
527+
/***
528+
* @param typeName type of the column
529+
* @return true if type name matches current type name or matches with one of postgres aliases
530+
* or if it matches equivalent postgres type.
531+
*/
532+
boolean matches(String typeName) {
533+
return getTypeName().equalsIgnoreCase(typeName)
534+
|| getPostgreSQLAliases().contains(typeName.toLowerCase())
535+
|| getSpannerType().getSpannerTypeName(Dialect.POSTGRESQL).equalsIgnoreCase(typeName);
536+
}
537+
501538
// TODO: Implement and use this method for all types.
502539
public int getPrecision() {
503540
throw new UnsupportedOperationException();

0 commit comments

Comments
 (0)