[jOOQ/jOOQ#10179] Boolean field emulation should be NOT NULL aware
This commit is contained in:
parent
e30c32bc8d
commit
8cbda1ca46
@ -66,23 +66,30 @@ final class ConditionAsField extends AbstractField<Boolean> {
|
||||
|
||||
// Some databases don't accept predicates where column expressions
|
||||
// are expected.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
case CUBRID:
|
||||
case FIREBIRD:
|
||||
|
||||
// [#3206] Correct implementation of three-valued logic is important here
|
||||
ctx.visit(DSL.when(condition, inline(true))
|
||||
.when(not(condition), inline(false))
|
||||
.otherwise(inline((Boolean) null)));
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// [#10179] Avoid 3VL when not necessary
|
||||
if (condition instanceof NotNullCondition)
|
||||
ctx.visit(DSL.when(condition, inline(true))
|
||||
.else_(inline(false)));
|
||||
|
||||
// [#3206] Implement 3VL if necessary or unknown
|
||||
else
|
||||
ctx.visit(DSL.when(condition, inline(true))
|
||||
.when(not(condition), inline(false))
|
||||
.else_(inline((Boolean) null)));
|
||||
break;
|
||||
|
||||
// These databases can inline predicates in column expression contexts
|
||||
|
||||
@ -51,7 +51,7 @@ import org.jooq.Select;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class ExistsCondition extends AbstractCondition {
|
||||
final class ExistsCondition extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
private static final long serialVersionUID = 5678338161136603292L;
|
||||
private static final Clause[] CLAUSES_EXISTS = { CONDITION, CONDITION_EXISTS };
|
||||
|
||||
@ -81,7 +81,7 @@ import org.jooq.SQLDialect;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class IsDistinctFrom<T> extends AbstractCondition {
|
||||
final class IsDistinctFrom<T> extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@ -47,7 +47,7 @@ import org.jooq.Field;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class IsDocument extends AbstractCondition {
|
||||
final class IsDocument extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -51,7 +51,7 @@ import org.jooq.Field;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class IsJSON extends AbstractCondition {
|
||||
final class IsJSON extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -54,7 +54,7 @@ import org.jooq.Field;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class IsNull extends AbstractCondition {
|
||||
final class IsNull extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
private static final long serialVersionUID = -747240442279619486L;
|
||||
private static final Clause[] CLAUSES_NULL = { CONDITION, CONDITION_IS_NULL };
|
||||
|
||||
46
jOOQ/src/main/java/org/jooq/impl/NotNullCondition.java
Normal file
46
jOOQ/src/main/java/org/jooq/impl/NotNullCondition.java
Normal file
@ -0,0 +1,46 @@
|
||||
/*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* Other licenses:
|
||||
* -----------------------------------------------------------------------------
|
||||
* Commercial licenses for this work are available. These replace the above
|
||||
* ASL 2.0 and offer limited warranties, support, maintenance, and commercial
|
||||
* database integrations.
|
||||
*
|
||||
* For more information, please visit: http://www.jooq.org/licenses
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
/**
|
||||
* A marker interface for conditions that can only be <code>TRUE</code> or
|
||||
* <code>FALSE</code>, never <code>NULL</code>.
|
||||
*
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
interface NotNullCondition {}
|
||||
@ -75,7 +75,7 @@ import org.jooq.SQLDialect;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class RowIsDistinctFrom extends AbstractCondition {
|
||||
final class RowIsDistinctFrom extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
|
||||
@ -37,9 +37,6 @@
|
||||
*/
|
||||
package org.jooq.impl;
|
||||
|
||||
import static org.jooq.Clause.CONDITION;
|
||||
import static org.jooq.Clause.CONDITION_IS_NOT_NULL;
|
||||
import static org.jooq.Clause.CONDITION_IS_NULL;
|
||||
// ...
|
||||
// ...
|
||||
// ...
|
||||
@ -85,14 +82,12 @@ import org.jooq.Table;
|
||||
/**
|
||||
* @author Lukas Eder
|
||||
*/
|
||||
final class RowIsNull extends AbstractCondition {
|
||||
final class RowIsNull extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
/**
|
||||
* Generated UID
|
||||
*/
|
||||
private static final long serialVersionUID = -1806139685201770706L;
|
||||
private static final Clause[] CLAUSES_NULL = { CONDITION, CONDITION_IS_NULL };
|
||||
private static final Clause[] CLAUSES_NOT_NULL = { CONDITION, CONDITION_IS_NOT_NULL };
|
||||
|
||||
// Currently not yet supported in SQLite:
|
||||
// https://www.sqlite.org/rowvalue.html
|
||||
|
||||
@ -54,7 +54,7 @@ import org.jooq.Table;
|
||||
/**
|
||||
* @author Knut Wannheden
|
||||
*/
|
||||
final class UniqueCondition extends AbstractCondition {
|
||||
final class UniqueCondition extends AbstractCondition implements NotNullCondition {
|
||||
|
||||
private static final long serialVersionUID = -5560973283201522844L;
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user