Skip to content

Commit

Permalink
[#4903] Emulate EVERY() with MAX() rather than with COUNT()
Browse files Browse the repository at this point in the history
  • Loading branch information
lukaseder committed Jan 6, 2016
1 parent 94f0bb2 commit 96e51c5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions jOOQ/src/main/java/org/jooq/impl/BoolAnd.java
Expand Up @@ -75,15 +75,15 @@ public final void accept(Context<?> ctx) {
break; break;


default: default:
final Field<Integer> count = DSL.field("{0}", Integer.class, new CustomQueryPart() { final Field<Integer> max = DSL.field("{0}", Integer.class, new CustomQueryPart() {
@Override @Override
public void accept(Context<?> c) { 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); 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; break;
} }
} }
Expand Down
6 changes: 3 additions & 3 deletions jOOQ/src/main/java/org/jooq/impl/BoolOr.java
Expand Up @@ -75,15 +75,15 @@ public final void accept(Context<?> ctx) {
break; break;


default: default:
final Field<Integer> count = DSL.field("{0}", Integer.class, new CustomQueryPart() { final Field<Integer> max = DSL.field("{0}", Integer.class, new CustomQueryPart() {
@Override @Override
public void accept(Context<?> c) { 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); 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; break;
} }
} }
Expand Down

0 comments on commit 96e51c5

Please sign in to comment.