[jOOQ/jOOQ#16508] More trivial NULL predicates

- Merge AbstractField::isPossiblyNullable with AbstractField::isNullable
- Override Array.isNullable() = false
- Use AbstractField::isNullable with transformPatternsTrivialPredicates
This commit is contained in:
Lukas Eder 2024-03-25 17:29:52 +01:00
parent 32b9d0bf8a
commit c379441d47
6 changed files with 32 additions and 14 deletions

View File

@ -113,11 +113,11 @@ implements
// ------------------------------------------------------------------------
/**
* [#10179] [#14665] Subclasses may override this method to indicate that
* the condition may produce <code>TRUE</code>, <code>FALSE</code>, or
* <code>NULL</code>.
* [#10179] [#11757] [#14665] Subclasses may override this method to
* indicate that the condition may produce <code>TRUE</code>,
* <code>FALSE</code>, or <code>NULL</code>.
*/
boolean isNullable() {
/* non-final */ boolean isNullable() {
return true;
}
@ -129,10 +129,6 @@ implements
return CLAUSES;
}
/* non-final */ boolean isPossiblyNullable() {
return true;
}
/* non-final */ int projectionSize() {
return 1;
}

View File

@ -91,7 +91,7 @@ abstract class AbstractParam<T> extends AbstractParamX<T> implements SimpleQuery
}
@Override
final boolean isPossiblyNullable() {
final boolean isNullable() {
return !inline || value == null;
}

View File

@ -66,7 +66,12 @@ import org.jooq.impl.QOM.UnmodifiableList;
/**
* @author Lukas Eder
*/
final class Array<T> extends AbstractField<T[]> implements QOM.Array<T> {
final class Array<T>
extends
AbstractField<T[]>
implements
QOM.Array<T>
{
static final Set<SQLDialect> REQUIRES_CAST = SQLDialect.supportedBy(POSTGRES, YUGABYTEDB);
static final Set<SQLDialect> NO_SUPPORT_SQUARE_BRACKETS = SQLDialect.supportedBy(CLICKHOUSE);
@ -79,6 +84,15 @@ final class Array<T> extends AbstractField<T[]> implements QOM.Array<T> {
this.fields = new FieldsImpl<>(fields);
}
// -------------------------------------------------------------------------
// XXX: QueryPart API
// -------------------------------------------------------------------------
@Override
final boolean isNullable() {
return false;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private static <T> DataType<T[]> type(Collection<? extends Field<T>> fields) {
if (fields == null || fields.isEmpty())

View File

@ -86,8 +86,8 @@ implements
}
@Override
boolean isPossiblyNullable() {
return field.isPossiblyNullable();
final boolean isNullable() {
return field.isNullable();
}
@Override

View File

@ -2696,6 +2696,14 @@ package org.jooq.impl;

View File

@ -4069,8 +4069,8 @@ final class Tools {
return part instanceof SeparatedQueryPart && ((SeparatedQueryPart) part).rendersSeparator();
}
static final boolean isPossiblyNullable(Field<?> f) {
return f instanceof AbstractField && ((AbstractField<?>) f).isPossiblyNullable();
static final boolean isNullable(Field<?> f) {
return f instanceof AbstractField && ((AbstractField<?>) f).isNullable();
}
static final Val<?> extractVal(Field<?> field) {