Skip to content

Commit

Permalink
fix: int4 is also not supported on real Spangres
Browse files Browse the repository at this point in the history
  • Loading branch information
olavloite committed Feb 21, 2024
1 parent 5e5131f commit b89612b
Showing 1 changed file with 13 additions and 18 deletions.
31 changes: 13 additions & 18 deletions src/test/java/com/google/cloud/spanner/pgadapter/ITJdbcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -318,8 +318,8 @@ public void testSelectWithParameters() throws SQLException {
statement.setBytes(++index, "test".getBytes(StandardCharsets.UTF_8));
}
statement.setDouble(++index, 3.14d);
// TODO: Remove when the emulator supports casting to int4
if (isSimpleMode && IntegrationTest.isRunningOnEmulator()) {
// TODO: Remove when Spangres supports casting to int4
if (isSimpleMode) {
statement.setLong(++index, 1);
} else {
statement.setInt(++index, 1);
Expand Down Expand Up @@ -387,8 +387,8 @@ public void testSelectWithParameters() throws SQLException {
assertArrayEquals(
new String[] {"string1", null, "string2"},
(String[]) resultSet.getArray(++index).getArray());
// TODO: Remove when the emulator supports casting to int4
if (!(isSimpleMode && IntegrationTest.isRunningOnEmulator())) {
// TODO: Remove when Spangres supports casting to int4
if (!isSimpleMode) {
assertArrayEquals(
new String[] {"{\"key\": \"value1\"}", null, "{\"key\": \"value2\"}"},
(String[]) resultSet.getArray(++index).getArray());
Expand Down Expand Up @@ -421,7 +421,7 @@ public void testInsertWithParameters() throws SQLException {
}
statement.setDouble(++index, 10.1);
// TODO: Remove when the emulator supports casting to int4
if (isSimpleMode && IntegrationTest.isRunningOnEmulator()) {
if (isSimpleMode) {
statement.setLong(++index, 100);
} else {
statement.setInt(++index, 100);
Expand Down Expand Up @@ -451,12 +451,11 @@ public void testInsertWithParameters() throws SQLException {
}
statement.setArray(
++index, connection.createArrayOf("float8", new Double[] {3.14d, null, -99.8}));
// TODO: Remove when the emulator supports casting to int4
// TODO: Remove when Spangres supports casting to int4
statement.setArray(
++index,
connection.createArrayOf(
isSimpleMode && IntegrationTest.isRunningOnEmulator() ? "bigint" : "int",
new Integer[] {-1, null, -2}));
isSimpleMode ? "bigint" : "int", new Integer[] {-1, null, -2}));
statement.setArray(
++index,
connection.createArrayOf(
Expand All @@ -480,7 +479,7 @@ public void testInsertWithParameters() throws SQLException {
++index,
connection.createArrayOf("varchar", new String[] {"string1", null, "string2"}));
// TODO: Remove when the emulator supports casting to int4
if (!(isSimpleMode && IntegrationTest.isRunningOnEmulator())) {
if (!isSimpleMode) {
statement.setArray(
++index,
connection.createArrayOf(
Expand Down Expand Up @@ -576,8 +575,8 @@ public void testInsertWithParameters() throws SQLException {
assertArrayEquals(
new String[] {"string1", null, "string2"},
(String[]) resultSet.getArray(++index).getArray());
// TODO: Remove when the emulator supports casting to int4
if (!(isSimpleMode && IntegrationTest.isRunningOnEmulator())) {
// TODO: Remove when Spangres supports casting to int4
if (!isSimpleMode) {
assertArrayEquals(
new String[] {
"{\"key1\": \"value1\", \"key2\": \"value2\"}",
Expand Down Expand Up @@ -617,8 +616,8 @@ public void testUpdateWithParameters() throws SQLException {
statement.setBytes(++index, "updated".getBytes(StandardCharsets.UTF_8));
}
statement.setDouble(++index, 3.14d * 2d);
// TODO: Remove when the emulator supports casting to int4
if (isSimpleMode && IntegrationTest.isRunningOnEmulator()) {
// TODO: Remove when Spangres supports casting to int4
if (isSimpleMode) {
statement.setLong(++index, 2);
} else {
statement.setInt(++index, 2);
Expand Down Expand Up @@ -923,11 +922,7 @@ public void testCopyIn_Large_SucceedsWhenNonAtomic() throws SQLException, IOExce

// Delete the imported data to prevent the cleanup method to fail on 'Too many mutations'
// when it tries to delete all data using a normal transaction.
connection
.createStatement()
.execute(
"delete from all_types"
+ (IntegrationTest.isRunningOnEmulator() ? " where true" : ""));
connection.createStatement().execute("delete from all_types");
}
}

Expand Down

0 comments on commit b89612b

Please sign in to comment.