From 96e51c5ff8632c8b3b759e6ab7329137402efcae Mon Sep 17 00:00:00 2001 From: lukaseder Date: Wed, 6 Jan 2016 23:01:02 +0100 Subject: [PATCH] [#4903] Emulate EVERY() with MAX() rather than with COUNT() --- jOOQ/src/main/java/org/jooq/impl/BoolAnd.java | 6 +++--- jOOQ/src/main/java/org/jooq/impl/BoolOr.java | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/jOOQ/src/main/java/org/jooq/impl/BoolAnd.java b/jOOQ/src/main/java/org/jooq/impl/BoolAnd.java index a6f5c01f56..52e65e484c 100644 --- a/jOOQ/src/main/java/org/jooq/impl/BoolAnd.java +++ b/jOOQ/src/main/java/org/jooq/impl/BoolAnd.java @@ -75,15 +75,15 @@ class BoolAnd extends Function { break; default: - final Field count = DSL.field("{0}", Integer.class, new CustomQueryPart() { + final Field 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; } } diff --git a/jOOQ/src/main/java/org/jooq/impl/BoolOr.java b/jOOQ/src/main/java/org/jooq/impl/BoolOr.java index 12c5e08d7a..2c5737cbc2 100644 --- a/jOOQ/src/main/java/org/jooq/impl/BoolOr.java +++ b/jOOQ/src/main/java/org/jooq/impl/BoolOr.java @@ -75,15 +75,15 @@ class BoolOr extends Function { break; default: - final Field count = DSL.field("{0}", Integer.class, new CustomQueryPart() { + final Field 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; } }