Added an integration test to ensure that bind values referenced multiple times can be changed in one go.

This commit is contained in:
Lukas Eder 2014-07-23 10:56:08 +02:00
parent 9fb8f8874f
commit 6cbf4ce1ff
2 changed files with 29 additions and 0 deletions

View File

@ -65,6 +65,7 @@ import java.util.Collections;
import org.jooq.DSLContext;
import org.jooq.Field;
import org.jooq.Insert;
import org.jooq.Param;
import org.jooq.Record;
import org.jooq.Record1;
import org.jooq.Record2;
@ -559,4 +560,27 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
.where(TBook_ID().eq(1))
.fetchOne(TBook_TITLE()));
}
public void testReusingBindValueReference() throws Exception {
// It should be possible to reuse bind value references multiple times and then
// change that value only once
Param<Integer> value = val(1);
Select<Record2<Integer,Integer>> query =
create().select(value.as("a"), value.as("b"))
.where(value.lt(3));
Record2<Integer, Integer> r1 = query.fetchOne();
assertEquals(1, (int) r1.value1());
assertEquals(1, (int) r1.value2());
value.setValue(2);
Record2<Integer, Integer> r2 = query.fetchOne();
assertEquals(2, (int) r2.value1());
assertEquals(2, (int) r2.value2());
value.setValue(3);
assertNull(query.fetchOne());
}
}

View File

@ -2834,6 +2834,11 @@ public abstract class jOOQAbstractTest<
new RenderAndBindTests(this).testInlinedBindValuesForDatetime();
}
@Test
public void testReusingBindValueReference() throws Exception {
new RenderAndBindTests(this).testReusingBindValueReference();
}
@Test
public void testUUIDDataType() throws Exception {
new DataTypeTests(this).testUUIDDataType();