[#4903] Emulate EVERY() with MAX() rather than with COUNT()

This commit is contained in:
lukaseder 2016-01-06 23:01:02 +01:00
parent 94f0bb2f69
commit 96e51c5ff8
2 changed files with 6 additions and 6 deletions

View File

@ -75,15 +75,15 @@ class BoolAnd extends Function<Boolean> {
break;
default:
final Field<Integer> count = DSL.field("{0}", Integer.class, new CustomQueryPart() {
final Field<Integer> max = DSL.field("{0}", Integer.class, new CustomQueryPart() {
@Override
public void accept(Context<?> c) {
c.visit(DSL.count(DSL.when(condition.not(), one())));
c.visit(DSL.max(DSL.when(condition, zero()).otherwise(one())));
toSQLOverClause(c);
}
});
ctx.visit(DSL.when(count.eq(zero()), inline(true)).otherwise(inline(false)));
ctx.visit(DSL.when(max.eq(zero()), inline(true)).otherwise(inline(false)));
break;
}
}

View File

@ -75,15 +75,15 @@ class BoolOr extends Function<Boolean> {
break;
default:
final Field<Integer> count = DSL.field("{0}", Integer.class, new CustomQueryPart() {
final Field<Integer> max = DSL.field("{0}", Integer.class, new CustomQueryPart() {
@Override
public void accept(Context<?> c) {
c.visit(DSL.count(DSL.when(condition, one())));
c.visit(DSL.max(DSL.when(condition, one()).otherwise(zero())));
toSQLOverClause(c);
}
});
ctx.visit(DSL.when(count.gt(zero()), inline(true)).otherwise(inline(false)));
ctx.visit(DSL.when(max.eq(one()), inline(true)).otherwise(inline(false)));
break;
}
}