|
17 | 17 | package com.google.cloud.spanner.jdbc.it; |
18 | 18 |
|
19 | 19 | import static com.google.common.truth.Truth.assertThat; |
| 20 | +import static org.junit.Assert.assertArrayEquals; |
20 | 21 | import static org.junit.Assert.assertEquals; |
21 | 22 | import static org.junit.Assert.assertFalse; |
22 | 23 | import static org.junit.Assert.assertThrows; |
23 | 24 | import static org.junit.Assert.assertTrue; |
24 | | -import static org.junit.Assert.fail; |
25 | 25 | import static org.junit.Assume.assumeFalse; |
26 | 26 |
|
27 | 27 | import com.google.cloud.spanner.Database; |
@@ -102,12 +102,6 @@ public void testSelect1PreparedStatement() throws SQLException { |
102 | 102 |
|
103 | 103 | @Test |
104 | 104 | public void testPreparedStatement() throws SQLException { |
105 | | - // skipping the test when dialect is POSTGRESQL because of exception below |
106 | | - // INVALID_ARGUMENT: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Statements with set |
107 | | - // operations in subqueries are not supported |
108 | | - assumeFalse( |
109 | | - "select array of structs is not supported on POSTGRESQL", |
110 | | - dialect.dialect == Dialect.POSTGRESQL); |
111 | 105 | String sql = |
112 | 106 | "select * from (select 1 as number union all select 2 union all select 3) numbers where number=?"; |
113 | 107 | try (Connection connection = createConnection(env, database)) { |
@@ -188,15 +182,16 @@ public void testBatchedDdlStatements() throws SQLException { |
188 | 182 | } |
189 | 183 |
|
190 | 184 | @Test |
191 | | - public void testAddBatchWhenAlreadyInBatch() { |
| 185 | + public void testAddBatchWhenAlreadyInBatch() throws SQLException { |
192 | 186 | try (Connection connection = createConnection(env, database)) { |
193 | | - connection.createStatement().execute("START BATCH DML"); |
194 | | - connection.createStatement().addBatch("INSERT INTO Singers (SingerId) VALUES (-1)"); |
195 | | - fail("missing expected exception"); |
196 | | - } catch (SQLException e) { |
197 | | - assertThat(e.getMessage()) |
198 | | - .contains( |
199 | | - "Calling addBatch() is not allowed when a DML or DDL batch has been started on the connection."); |
| 187 | + try (Statement statement = connection.createStatement()) { |
| 188 | + statement.execute("START BATCH DML"); |
| 189 | + statement.addBatch("INSERT INTO Singers (SingerId) VALUES (-1)"); |
| 190 | + statement.addBatch("INSERT INTO Singers (SingerId) VALUES (-2)"); |
| 191 | + // The returned update count for DML statements in a batch is -1. |
| 192 | + assertArrayEquals(new int[] {-1, -1}, statement.executeBatch()); |
| 193 | + // Note: The 'Singers' table does not actually exist, so we're not executing the batch. |
| 194 | + } |
200 | 195 | } |
201 | 196 | } |
202 | 197 |
|
|
0 commit comments