[#2152] Invalid column type: 16, when binding null as java.lang.Boolean onto a NUMBER(..) column in Oracle
This commit is contained in:
parent
abf1ae51ee
commit
5ffaac2e39
@ -42,6 +42,9 @@ package org.jooq.test._.testcases;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static org.jooq.tools.reflect.Reflect.on;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.sql.Date;
|
||||
import java.util.List;
|
||||
@ -147,9 +150,9 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
.set(TBooleans_Boolean_YES_NO_UC(), Boolean_YES_NO_UC.NO)
|
||||
.set(TBooleans_Boolean_YN_LC(), Boolean_YN_LC.n)
|
||||
.set(TBooleans_Boolean_YN_UC(), Boolean_YN_UC.N)
|
||||
// .set(TBooleans_C(), false)
|
||||
// .set(TBooleans_VC(), false)
|
||||
// .set(TBooleans_N(), false)
|
||||
.set(TBooleans_C(), false)
|
||||
.set(TBooleans_VC(), false)
|
||||
.set(TBooleans_N(), false)
|
||||
.execute());
|
||||
|
||||
assertEquals(1,
|
||||
@ -162,58 +165,91 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
.set(TBooleans_Boolean_YES_NO_UC(), Boolean_YES_NO_UC.YES)
|
||||
.set(TBooleans_Boolean_YN_LC(), Boolean_YN_LC.y)
|
||||
.set(TBooleans_Boolean_YN_UC(), Boolean_YN_UC.Y)
|
||||
// .set(TBooleans_C(), true)
|
||||
// .set(TBooleans_VC(), true)
|
||||
// .set(TBooleans_N(), true)
|
||||
.set(TBooleans_C(), true)
|
||||
.set(TBooleans_VC(), true)
|
||||
.set(TBooleans_N(), true)
|
||||
.execute());
|
||||
|
||||
assertEquals(1,
|
||||
create().insertInto(TBooleans())
|
||||
.set(TBooleans_ID(), 3)
|
||||
.set(TBooleans_BOOLEAN_10(), (Boolean_10) null)
|
||||
.set(TBooleans_Boolean_TF_LC(), (Boolean_TF_LC) null)
|
||||
.set(TBooleans_Boolean_TF_UC(), (Boolean_TF_UC) null)
|
||||
.set(TBooleans_Boolean_YES_NO_LC(), (Boolean_YES_NO_LC) null)
|
||||
.set(TBooleans_Boolean_YES_NO_UC(), (Boolean_YES_NO_UC) null)
|
||||
.set(TBooleans_Boolean_YN_LC(), (Boolean_YN_LC) null)
|
||||
.set(TBooleans_Boolean_YN_UC(), (Boolean_YN_UC) null)
|
||||
.set(TBooleans_C(), (Boolean) null)
|
||||
.set(TBooleans_VC(), (Boolean) null)
|
||||
.set(TBooleans_N(), (Boolean) null)
|
||||
.execute());
|
||||
|
||||
// Selection
|
||||
// --------------------------------------------------------------------
|
||||
Result<?> result =
|
||||
create().selectFrom(TBooleans())
|
||||
.where(TBooleans_ID().in(1, 2))
|
||||
.and(TBooleans_BOOLEAN_10().in(Boolean_10.ONE, Boolean_10.ZERO))
|
||||
.and(TBooleans_Boolean_TF_LC().in(Boolean_TF_LC.TRUE, Boolean_TF_LC.FALSE))
|
||||
.and(TBooleans_Boolean_TF_UC().in(Boolean_TF_UC.TRUE, Boolean_TF_UC.FALSE))
|
||||
.and(TBooleans_Boolean_YES_NO_LC().in(Boolean_YES_NO_LC.yes, Boolean_YES_NO_LC.no))
|
||||
.and(TBooleans_Boolean_YES_NO_UC().in(Boolean_YES_NO_UC.YES, Boolean_YES_NO_UC.NO))
|
||||
.and(TBooleans_Boolean_YN_LC().in(Boolean_YN_LC.y, Boolean_YN_LC.n))
|
||||
.and(TBooleans_Boolean_YN_UC().in(Boolean_YN_UC.Y, Boolean_YN_UC.N))
|
||||
.where(TBooleans_ID().in(1, 2, 3))
|
||||
.and(TBooleans_BOOLEAN_10().in(Boolean_10.ONE, Boolean_10.ZERO)
|
||||
.or(TBooleans_BOOLEAN_10().isNull()))
|
||||
.and(TBooleans_Boolean_TF_LC().in(Boolean_TF_LC.TRUE, Boolean_TF_LC.FALSE)
|
||||
.or(TBooleans_Boolean_TF_LC().isNull()))
|
||||
.and(TBooleans_Boolean_TF_UC().in(Boolean_TF_UC.TRUE, Boolean_TF_UC.FALSE)
|
||||
.or(TBooleans_Boolean_TF_UC().isNull()))
|
||||
.and(TBooleans_Boolean_YES_NO_LC().in(Boolean_YES_NO_LC.yes, Boolean_YES_NO_LC.no)
|
||||
.or(TBooleans_Boolean_YES_NO_LC().isNull()))
|
||||
.and(TBooleans_Boolean_YES_NO_UC().in(Boolean_YES_NO_UC.YES, Boolean_YES_NO_UC.NO)
|
||||
.or(TBooleans_Boolean_YES_NO_UC().isNull()))
|
||||
.and(TBooleans_Boolean_YN_LC().in(Boolean_YN_LC.y, Boolean_YN_LC.n)
|
||||
.or(TBooleans_Boolean_YN_LC().isNull()))
|
||||
.and(TBooleans_Boolean_YN_UC().in(Boolean_YN_UC.Y, Boolean_YN_UC.N)
|
||||
.or(TBooleans_Boolean_YN_UC().isNull()))
|
||||
.orderBy(TBooleans_ID().asc())
|
||||
.fetch();
|
||||
|
||||
assertEquals(1, (int) result.getValue(0, TBooleans_ID()));
|
||||
assertEquals(2, (int) result.getValue(1, TBooleans_ID()));
|
||||
assertEquals(3, (int) result.getValue(2, TBooleans_ID()));
|
||||
|
||||
assertEquals(Boolean_10.ZERO, result.getValue(0, TBooleans_BOOLEAN_10()));
|
||||
assertEquals(Boolean_10.ONE, result.getValue(1, TBooleans_BOOLEAN_10()));
|
||||
assertNull(result.getValue(2, TBooleans_BOOLEAN_10()));
|
||||
|
||||
assertEquals(Boolean_TF_LC.FALSE, result.getValue(0, TBooleans_Boolean_TF_LC()));
|
||||
assertEquals(Boolean_TF_LC.TRUE, result.getValue(1, TBooleans_Boolean_TF_LC()));
|
||||
assertNull(result.getValue(2, TBooleans_Boolean_TF_LC()));
|
||||
|
||||
assertEquals(Boolean_TF_UC.FALSE, result.getValue(0, TBooleans_Boolean_TF_UC()));
|
||||
assertEquals(Boolean_TF_UC.TRUE, result.getValue(1, TBooleans_Boolean_TF_UC()));
|
||||
assertNull(result.getValue(2, TBooleans_Boolean_TF_UC()));
|
||||
|
||||
assertEquals(Boolean_YES_NO_LC.no, result.getValue(0, TBooleans_Boolean_YES_NO_LC()));
|
||||
assertEquals(Boolean_YES_NO_LC.yes, result.getValue(1, TBooleans_Boolean_YES_NO_LC()));
|
||||
assertNull(result.getValue(2, TBooleans_Boolean_YES_NO_LC()));
|
||||
|
||||
assertEquals(Boolean_YES_NO_UC.NO, result.getValue(0, TBooleans_Boolean_YES_NO_UC()));
|
||||
assertEquals(Boolean_YES_NO_UC.YES, result.getValue(1, TBooleans_Boolean_YES_NO_UC()));
|
||||
assertNull(result.getValue(2, TBooleans_Boolean_YES_NO_UC()));
|
||||
|
||||
assertEquals(Boolean_YN_LC.n, result.getValue(0, TBooleans_Boolean_YN_LC()));
|
||||
assertEquals(Boolean_YN_LC.y, result.getValue(1, TBooleans_Boolean_YN_LC()));
|
||||
assertNull(result.getValue(2, TBooleans_Boolean_YN_LC()));
|
||||
|
||||
assertEquals(Boolean_YN_UC.N, result.getValue(0, TBooleans_Boolean_YN_UC()));
|
||||
assertEquals(Boolean_YN_UC.Y, result.getValue(1, TBooleans_Boolean_YN_UC()));
|
||||
assertNull(result.getValue(2, TBooleans_Boolean_YN_UC()));
|
||||
|
||||
// assertFalse(result.getValue(0, TBooleans_C()));
|
||||
// assertTrue(result.getValue(1, TBooleans_C()));
|
||||
//
|
||||
// assertFalse(result.getValue(0, TBooleans_VC()));
|
||||
// assertTrue(result.getValue(1, TBooleans_VC()));
|
||||
//
|
||||
// assertFalse(result.getValue(0, TBooleans_N()));
|
||||
// assertTrue(result.getValue(1, TBooleans_N()));
|
||||
assertFalse(result.getValue(0, TBooleans_C()));
|
||||
assertTrue(result.getValue(1, TBooleans_C()));
|
||||
assertNull(result.getValue(2, TBooleans_C()));
|
||||
|
||||
assertFalse(result.getValue(0, TBooleans_VC()));
|
||||
assertTrue(result.getValue(1, TBooleans_VC()));
|
||||
assertNull(result.getValue(2, TBooleans_VC()));
|
||||
|
||||
assertFalse(result.getValue(0, TBooleans_N()));
|
||||
assertTrue(result.getValue(1, TBooleans_N()));
|
||||
assertNull(result.getValue(2, TBooleans_N()));
|
||||
|
||||
// Conversion to custom POJOs
|
||||
// --------------------------------------------------------------------
|
||||
@ -226,30 +262,38 @@ extends BaseTest<A, AP, B, S, B2S, BS, L, X, DATE, BOOL, D, T, U, UU, I, IPK, T7
|
||||
.orderBy(TBooleans_ID().asc())
|
||||
.fetchInto(TBooleansPojo());
|
||||
|
||||
assertEquals(2, b.size());
|
||||
assertEquals(3, b.size());
|
||||
assertEquals(1, on(b.get(0)).call("getId").get());
|
||||
assertEquals(2, on(b.get(1)).call("getId").get());
|
||||
assertEquals(3, on(b.get(2)).call("getId").get());
|
||||
|
||||
assertEquals(Boolean_10.ZERO, on(b.get(0)).call("getOneZero").get());
|
||||
assertEquals(Boolean_10.ONE, on(b.get(1)).call("getOneZero").get());
|
||||
assertNull(on(b.get(2)).call("getOneZero").get());
|
||||
|
||||
assertEquals(Boolean_TF_LC.FALSE, on(b.get(0)).call("getTrueFalseLc").get());
|
||||
assertEquals(Boolean_TF_LC.TRUE, on(b.get(1)).call("getTrueFalseLc").get());
|
||||
assertNull(on(b.get(2)).call("getTrueFalseLc").get());
|
||||
|
||||
assertEquals(Boolean_TF_UC.FALSE, on(b.get(0)).call("getTrueFalseUc").get());
|
||||
assertEquals(Boolean_TF_UC.TRUE, on(b.get(1)).call("getTrueFalseUc").get());
|
||||
assertNull(on(b.get(2)).call("getTrueFalseUc").get());
|
||||
|
||||
assertEquals(Boolean_YES_NO_LC.no, on(b.get(0)).call("getYesNoLc").get());
|
||||
assertEquals(Boolean_YES_NO_LC.yes, on(b.get(1)).call("getYesNoLc").get());
|
||||
assertNull(on(b.get(2)).call("getYesNoLc").get());
|
||||
|
||||
assertEquals(Boolean_YES_NO_UC.NO, on(b.get(0)).call("getYesNoUc").get());
|
||||
assertEquals(Boolean_YES_NO_UC.YES, on(b.get(1)).call("getYesNoUc").get());
|
||||
assertNull(on(b.get(2)).call("getYesNoUc").get());
|
||||
|
||||
assertEquals(Boolean_YN_LC.n, on(b.get(0)).call("getYNLc").get());
|
||||
assertEquals(Boolean_YN_LC.y, on(b.get(1)).call("getYNLc").get());
|
||||
assertNull(on(b.get(2)).call("getYNLc").get());
|
||||
|
||||
assertEquals(Boolean_YN_UC.N, on(b.get(0)).call("getYNUc").get());
|
||||
assertEquals(Boolean_YN_UC.Y, on(b.get(1)).call("getYNUc").get());
|
||||
assertNull(on(b.get(2)).call("getYNUc").get());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -42,6 +42,7 @@ package org.jooq.impl;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
// ...
|
||||
// ...
|
||||
import static org.jooq.SQLDialect.POSTGRES;
|
||||
import static org.jooq.SQLDialect.SQLITE;
|
||||
// ...
|
||||
@ -172,6 +173,12 @@ class DefaultBindContext extends AbstractBindContext {
|
||||
x
|
||||
x
|
||||
|
||||
xx xxxxxxx xxxxxx xxxxxx xxxx xxx xxxx xxxxxxxx xxx xxx xxxx xxxxxx
|
||||
xx xxxxxx xxx xxx xxxxxxx xxxxx
|
||||
xxxx xx xxxxxxxx xx xxxxxxxxxxxxx xx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx xx xxxxxxx x
|
||||
xxxxxxxxxxxxxxxxxxxxxxxxxxx xxxxxx
|
||||
x
|
||||
|
||||
xx [/pro] */
|
||||
// All other types can be set to null if the JDBC type is known
|
||||
else if (sqlType != Types.OTHER) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user