|
19 | 19 | import java.time.LocalDateTime; |
20 | 20 | import java.time.LocalTime; |
21 | 21 | import java.util.Arrays; |
| 22 | +import java.util.List; |
22 | 23 | import java.util.Properties; |
23 | 24 | import java.util.stream.IntStream; |
24 | 25 |
|
|
27 | 28 | import static org.firebirdsql.common.FBTestProperties.getDefaultPropertiesForConnection; |
28 | 29 | import static org.firebirdsql.common.FBTestProperties.getUrl; |
29 | 30 | import static org.firebirdsql.common.FbAssumptions.assumeServerBatchSupport; |
| 31 | +import static org.firebirdsql.common.assertions.ResultSetAssertions.assertNextRow; |
| 32 | +import static org.firebirdsql.common.assertions.ResultSetAssertions.assertNoNextRow; |
| 33 | +import static org.firebirdsql.common.assertions.ResultSetAssertions.assertRowEquals; |
30 | 34 | import static org.firebirdsql.common.matchers.SQLExceptionMatchers.message; |
31 | 35 | import static org.hamcrest.MatcherAssert.assertThat; |
32 | 36 | import static org.hamcrest.Matchers.containsString; |
@@ -384,6 +388,36 @@ void testPreparedStatementBatch_65Blobs() throws SQLException { |
384 | 388 | } |
385 | 389 | } |
386 | 390 |
|
| 391 | + /** |
| 392 | + * Rationale: see <a href="https://github.com/FirebirdSQL/jaybird/issues/888">#888</a>. |
| 393 | + */ |
| 394 | + @ParameterizedTest(name = "[{index}] useServerBatch = {0}") |
| 395 | + @ValueSource(booleans = { true, false }) |
| 396 | + void testBatchMultipleEmptyStringsInBlob(boolean useServerBatch) throws Exception { |
| 397 | + try (var connection = createConnection(useServerBatch); |
| 398 | + var stmt = connection.createStatement()) { |
| 399 | + stmt.execute(RECREATE_BATCH_UPDATES_TABLE); |
| 400 | + connection.setAutoCommit(false); |
| 401 | + try (var ps = connection.prepareStatement("INSERT INTO batch_updates(id, clob_value) VALUES (?, ?)")) { |
| 402 | + ps.setInt(1, 1); |
| 403 | + ps.setString(2, ""); |
| 404 | + ps.addBatch(); |
| 405 | + ps.setInt(1, 2); |
| 406 | + ps.setString(2, ""); |
| 407 | + ps.addBatch(); |
| 408 | + assertDoesNotThrow(ps::executeBatch); |
| 409 | + } |
| 410 | + |
| 411 | + try (var rs = stmt.executeQuery("select ID, CLOB_VALUE from BATCH_UPDATES order by ID")) { |
| 412 | + assertNextRow(rs); |
| 413 | + assertRowEquals(rs, List.of(1, "")); |
| 414 | + assertNextRow(rs); |
| 415 | + assertRowEquals(rs, List.of(2, "")); |
| 416 | + assertNoNextRow(rs); |
| 417 | + } |
| 418 | + } |
| 419 | + } |
| 420 | + |
387 | 421 | private static Connection createConnection(boolean useServerBatch) throws SQLException { |
388 | 422 | Properties props = getDefaultPropertiesForConnection(); |
389 | 423 | props.setProperty(PropertyNames.useServerBatch, String.valueOf(useServerBatch)); |
|
0 commit comments