[jOOQ/jOOQ#16368] Parser always parses NULL literal of type BOOLEAN

This commit is contained in:
Lukas Eder 2024-02-28 14:41:28 +01:00
parent eaf1a766b5
commit c65e1e1cd0
3 changed files with 26 additions and 20 deletions

View File

@ -11860,7 +11860,7 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return null;
}
private final Field<Boolean> parseBooleanValueExpressionIf() {
private final Field<?> parseBooleanValueExpressionIf() {
TruthValue truth = parseTruthValueIf();
if (truth != null) {
@ -11869,8 +11869,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext {
return inline(true);
case T_FALSE:
return inline(false);
// [#16368] We cannot decide the data type at this point
case T_NULL:
return inline((Boolean) null);
return inline(null, OTHER);
default:
throw exception("Truth value not supported: " + truth);
}

View File

@ -2692,24 +2692,6 @@ package org.jooq.impl;

View File

@ -3979,6 +3979,28 @@ final class Tools {
|| field instanceof ConvertedVal && ((ConvertedVal<?>) field).delegate instanceof Val;
}
static final boolean isVal(QueryPart p, Predicate<? super Val<?>> predicate) {
if (p instanceof Val<?> v) {
return predicate.test(v);
}
else if (p instanceof ConvertedVal<?> v) {
return isVal(v.delegate, predicate);
}
else
return false;
}
static final <T> boolean isVal0(Field<T> p, Predicate<? super Val<T>> predicate) {
if (p instanceof Val<T> v) {
return predicate.test(v);
}
else if (p instanceof ConvertedVal<T> v) {
return isVal0((Field<T>) v.delegate, predicate);
}
else
return false;
}
static final boolean isWindow(QueryPart part) {
return part instanceof AbstractWindowFunction && ((AbstractWindowFunction<?>) part).isWindow();
}