[#2675] Add test to verify if jOOQ correctly binds NULL values with the right JDBC type in batch INSERT operations

This commit is contained in:
Lukas Eder 2014-04-08 17:56:38 +02:00
parent 52bf076a1e
commit 205969cfc8
2 changed files with 27 additions and 0 deletions

View File

@ -41,6 +41,7 @@
package org.jooq.test._.testcases;
import static java.util.Arrays.asList;
import static java.util.Collections.nCopies;
import static org.jooq.impl.DSL.delete;
import static org.jooq.impl.DSL.insertInto;
import static org.jooq.impl.DSL.selectOne;
@ -152,6 +153,27 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
testBatchAuthors("Gamma", "Helm", "Johnson");
}
@Test
public void testBatchSingleWithNulls() throws Exception {
Batch batch = create().batch(insertInto(TDates(), TDates_ID(), TDates_D(), TDates_T(), TDates_TS())
.values(1, null, null, null))
.bind(1, null, null, null)
.bind(2, null, null, null)
.bind(3, null, null, null);
assertEquals(3, batch.size());
int[] result = batch.execute();
assertEquals(3, result.length);
Result<DATE> dates = create().fetch(TDates());
assertEquals(3, dates.size());
assertEquals(asList(1, 2, 3), dates.getValues(TDates_ID()));
assertEquals(nCopies(3, null), dates.getValues(TDates_D()));
assertEquals(nCopies(3, null), dates.getValues(TDates_T()));
assertEquals(nCopies(3, null), dates.getValues(TDates_TS()));
}
@Test
public void testBatchMultiple() throws Exception {
jOOQAbstractTest.reset = false;

View File

@ -2431,6 +2431,11 @@ public abstract class jOOQAbstractTest<
new BatchTests(this).testBatchSingle();
}
@Test
public void testBatchSingleWithNulls() throws Exception {
new BatchTests(this).testBatchSingleWithNulls();
}
@Test
public void testBatchMultiple() throws Exception {
new BatchTests(this).testBatchMultiple();