[jOOQ/jOOQ#11958] BOOL_AND() and BOOL_OR() emulation does not correctly implement FILTER clause
This commit is contained in:
parent
16da30bbfd
commit
178b844fe3
@ -360,6 +360,10 @@ implements
|
||||
return this;
|
||||
}
|
||||
|
||||
final Condition f(Condition c) {
|
||||
return filter != null ? filter.and(c) : c;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
final <U> Field<U> fon(AggregateFunction<U> function) {
|
||||
return DSL.nullif(fo(function), (Field<U>) zero());
|
||||
|
||||
@ -254,8 +254,7 @@ extends
|
||||
private final <N extends Number> Condition bitCheck(Field<N> field, N mask) {
|
||||
|
||||
// [#11956] TODO: Potentially refactor this to use GETBIT()
|
||||
Condition c = DSL.bitAnd(field, inline(mask)).eq(inline(mask));
|
||||
return filter != null ? filter.and(c) : c;
|
||||
return f(DSL.bitAnd(field, inline(mask)).eq(inline(mask)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -87,12 +87,8 @@ final class BoolAnd extends DefaultAggregateFunction<Boolean> {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (EMULATE.contains(ctx.dialect())) {
|
||||
ctx.visit(DSL.field(DSL.field("{0}", Integer.class, CustomQueryPart.of(c -> {
|
||||
c.visit(DSL.min(DSL.when(condition, one()).otherwise(zero())));
|
||||
acceptOverClause(c);
|
||||
})).eq(one())));
|
||||
}
|
||||
if (EMULATE.contains(ctx.dialect()))
|
||||
ctx.visit(fo(DSL.min(DSL.when(condition, one()).otherwise(zero()))).eq(one()));
|
||||
else
|
||||
super.accept(ctx);
|
||||
}
|
||||
|
||||
@ -112,12 +112,8 @@ final class BoolOr extends DefaultAggregateFunction<Boolean> {
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
if (EMULATE.contains(ctx.dialect())) {
|
||||
ctx.visit(DSL.field(DSL.field("{0}", Integer.class, CustomQueryPart.of(c -> {
|
||||
c.visit(DSL.max(DSL.when(condition, one()).otherwise(zero())));
|
||||
acceptOverClause(c);
|
||||
})).eq(one())));
|
||||
}
|
||||
if (EMULATE.contains(ctx.dialect()))
|
||||
ctx.visit(fo(DSL.max(DSL.when(condition, one()).otherwise(zero()))).eq(one()));
|
||||
else
|
||||
super.accept(ctx);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user