|
34 | 34 | import java.time.LocalDateTime; |
35 | 35 | import java.time.LocalTime; |
36 | 36 | import java.util.Arrays; |
| 37 | +import java.util.List; |
37 | 38 | import java.util.Properties; |
38 | 39 | import java.util.stream.IntStream; |
39 | 40 |
|
|
42 | 43 | import static org.firebirdsql.common.FBTestProperties.getDefaultPropertiesForConnection; |
43 | 44 | import static org.firebirdsql.common.FBTestProperties.getUrl; |
44 | 45 | import static org.firebirdsql.common.FbAssumptions.assumeServerBatchSupport; |
| 46 | +import static org.firebirdsql.common.assertions.ResultSetAssertions.assertNextRow; |
| 47 | +import static org.firebirdsql.common.assertions.ResultSetAssertions.assertNoNextRow; |
| 48 | +import static org.firebirdsql.common.assertions.ResultSetAssertions.assertRowEquals; |
45 | 49 | import static org.firebirdsql.common.matchers.SQLExceptionMatchers.message; |
46 | 50 | import static org.hamcrest.MatcherAssert.assertThat; |
47 | 51 | import static org.hamcrest.Matchers.containsString; |
@@ -399,6 +403,36 @@ void testPreparedStatementBatch_65Blobs() throws SQLException { |
399 | 403 | } |
400 | 404 | } |
401 | 405 |
|
| 406 | + /** |
| 407 | + * Rationale: see <a href="https://github.com/FirebirdSQL/jaybird/issues/888">#888</a>. |
| 408 | + */ |
| 409 | + @ParameterizedTest(name = "[{index}] useServerBatch = {0}") |
| 410 | + @ValueSource(booleans = { true, false }) |
| 411 | + void testBatchMultipleEmptyStringsInBlob(boolean useServerBatch) throws Exception { |
| 412 | + try (var connection = createConnection(useServerBatch); |
| 413 | + var stmt = connection.createStatement()) { |
| 414 | + stmt.execute(RECREATE_BATCH_UPDATES_TABLE); |
| 415 | + connection.setAutoCommit(false); |
| 416 | + try (var ps = connection.prepareStatement("INSERT INTO batch_updates(id, clob_value) VALUES (?, ?)")) { |
| 417 | + ps.setInt(1, 1); |
| 418 | + ps.setString(2, ""); |
| 419 | + ps.addBatch(); |
| 420 | + ps.setInt(1, 2); |
| 421 | + ps.setString(2, ""); |
| 422 | + ps.addBatch(); |
| 423 | + assertDoesNotThrow(ps::executeBatch); |
| 424 | + } |
| 425 | + |
| 426 | + try (var rs = stmt.executeQuery("select ID, CLOB_VALUE from BATCH_UPDATES order by ID")) { |
| 427 | + assertNextRow(rs); |
| 428 | + assertRowEquals(rs, List.of(1, "")); |
| 429 | + assertNextRow(rs); |
| 430 | + assertRowEquals(rs, List.of(2, "")); |
| 431 | + assertNoNextRow(rs); |
| 432 | + } |
| 433 | + } |
| 434 | + } |
| 435 | + |
402 | 436 | private static Connection createConnection(boolean useServerBatch) throws SQLException { |
403 | 437 | Properties props = getDefaultPropertiesForConnection(); |
404 | 438 | props.setProperty(PropertyNames.useServerBatch, String.valueOf(useServerBatch)); |
|
0 commit comments