|
35 | 35 | import java.time.LocalDateTime; |
36 | 36 | import java.time.LocalTime; |
37 | 37 | import java.util.Arrays; |
| 38 | +import java.util.List; |
38 | 39 | import java.util.Properties; |
39 | 40 | import java.util.stream.IntStream; |
40 | 41 |
|
41 | 42 | import static java.nio.charset.StandardCharsets.US_ASCII; |
42 | 43 | import static org.firebirdsql.common.FBTestProperties.getConnectionViaDriverManager; |
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; |
@@ -357,6 +361,36 @@ void testPreparedStatementExecuteBatch_endAtFirstFailure(boolean useServerBatch) |
357 | 361 | } |
358 | 362 | } |
359 | 363 |
|
| 364 | + /** |
| 365 | + * Rationale: see <a href="https://github.com/FirebirdSQL/jaybird/issues/888">#888</a>. |
| 366 | + */ |
| 367 | + @ParameterizedTest(name = "[{index}] useServerBatch = {0}") |
| 368 | + @ValueSource(booleans = { true, false }) |
| 369 | + void testBatchMultipleEmptyStringsInBlob(boolean useServerBatch) throws Exception { |
| 370 | + try (Connection connection = createConnection(useServerBatch); |
| 371 | + Statement stmt = connection.createStatement()) { |
| 372 | + stmt.execute(RECREATE_BATCH_UPDATES_TABLE); |
| 373 | + connection.setAutoCommit(false); |
| 374 | + try (PreparedStatement ps = connection.prepareStatement("INSERT INTO batch_updates(id, clob_value) VALUES (?, ?)")) { |
| 375 | + ps.setInt(1, 1); |
| 376 | + ps.setString(2, ""); |
| 377 | + ps.addBatch(); |
| 378 | + ps.setInt(1, 2); |
| 379 | + ps.setString(2, ""); |
| 380 | + ps.addBatch(); |
| 381 | + assertDoesNotThrow(ps::executeBatch); |
| 382 | + } |
| 383 | + |
| 384 | + try (ResultSet rs = stmt.executeQuery("select ID, CLOB_VALUE from BATCH_UPDATES order by ID")) { |
| 385 | + assertNextRow(rs); |
| 386 | + assertRowEquals(rs, List.of(1, "")); |
| 387 | + assertNextRow(rs); |
| 388 | + assertRowEquals(rs, List.of(2, "")); |
| 389 | + assertNoNextRow(rs); |
| 390 | + } |
| 391 | + } |
| 392 | + } |
| 393 | + |
360 | 394 | private static Connection createConnection(boolean useServerBatch) throws SQLException { |
361 | 395 | Properties props = FBTestProperties.getDefaultPropertiesForConnection(); |
362 | 396 | props.setProperty(PropertyNames.useServerBatch, String.valueOf(useServerBatch)); |
|
0 commit comments