Skip to content

Commit 37999a6

Browse files
committed
#888 Test to demonstrate Jaybird 5 is not affected
1 parent 853e894 commit 37999a6

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

src/test/org/firebirdsql/jdbc/BatchUpdatesTest.java

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,17 @@
3535
import java.time.LocalDateTime;
3636
import java.time.LocalTime;
3737
import java.util.Arrays;
38+
import java.util.List;
3839
import java.util.Properties;
3940
import java.util.stream.IntStream;
4041

4142
import static java.nio.charset.StandardCharsets.US_ASCII;
4243
import static org.firebirdsql.common.FBTestProperties.getConnectionViaDriverManager;
4344
import static org.firebirdsql.common.FBTestProperties.getUrl;
4445
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;
4549
import static org.firebirdsql.common.matchers.SQLExceptionMatchers.message;
4650
import static org.hamcrest.MatcherAssert.assertThat;
4751
import static org.hamcrest.Matchers.containsString;
@@ -357,6 +361,36 @@ void testPreparedStatementExecuteBatch_endAtFirstFailure(boolean useServerBatch)
357361
}
358362
}
359363

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+
360394
private static Connection createConnection(boolean useServerBatch) throws SQLException {
361395
Properties props = FBTestProperties.getDefaultPropertiesForConnection();
362396
props.setProperty(PropertyNames.useServerBatch, String.valueOf(useServerBatch));

0 commit comments

Comments
 (0)