From 097f26e0d182904bf1911a70ce81f42e952e4ae5 Mon Sep 17 00:00:00 2001 From: Lukas Eder Date: Fri, 27 Jan 2023 16:29:00 +0100 Subject: [PATCH] [jOOQ/jOOQ#13640] Move QuantifiedComparisonCondition to QOM API - Refactored it into individual types (e.g. EqQuantified, NeQuantified) - Fix a regression in Array caused by [jOOQ/jOOQ#14560] --- jOOQ/src/main/java/org/jooq/Field.java | 320 +++++--------- .../java/org/jooq/impl/AbstractField.java | 175 ++++---- jOOQ/src/main/java/org/jooq/impl/Array.java | 2 +- .../main/java/org/jooq/impl/EqQuantified.java | 402 ++++++++++++++++++ .../main/java/org/jooq/impl/GeQuantified.java | 160 +++++++ .../main/java/org/jooq/impl/GtQuantified.java | 160 +++++++ .../main/java/org/jooq/impl/LeQuantified.java | 160 +++++++ .../java/org/jooq/impl/LikeQuantified.java | 197 +++++++++ .../main/java/org/jooq/impl/LtQuantified.java | 160 +++++++ .../main/java/org/jooq/impl/NeQuantified.java | 160 +++++++ .../java/org/jooq/impl/NotLikeQuantified.java | 197 +++++++++ .../org/jooq/impl/NotSimilarToQuantified.java | 197 +++++++++ jOOQ/src/main/java/org/jooq/impl/QOM.java | 168 +++++++- .../impl/QuantifiedComparisonCondition.java | 343 --------------- .../org/jooq/impl/SimilarToQuantified.java | 197 +++++++++ 15 files changed, 2374 insertions(+), 624 deletions(-) create mode 100644 jOOQ/src/main/java/org/jooq/impl/EqQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/GeQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/GtQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/LeQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/LikeQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/LtQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/NeQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/NotLikeQuantified.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/NotSimilarToQuantified.java delete mode 100644 jOOQ/src/main/java/org/jooq/impl/QuantifiedComparisonCondition.java create mode 100644 jOOQ/src/main/java/org/jooq/impl/SimilarToQuantified.java diff --git a/jOOQ/src/main/java/org/jooq/Field.java b/jOOQ/src/main/java/org/jooq/Field.java index a748eaf1de..c827f1e867 100644 --- a/jOOQ/src/main/java/org/jooq/Field.java +++ b/jOOQ/src/main/java/org/jooq/Field.java @@ -660,6 +660,13 @@ extends @Support Condition eq(Field arg2); + /** + * The EQ operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition eq(org.jooq.QuantifiedSelect> arg2); + /** * The EQUAL operator, an alias for the EQ operator. */ @@ -681,6 +688,13 @@ extends @Support Condition equal(Field arg2); + /** + * The EQUAL operator, an alias for the EQ operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition equal(org.jooq.QuantifiedSelect> arg2); + /** * The GE operator. */ @@ -702,6 +716,13 @@ extends @Support Condition ge(Field arg2); + /** + * The GE operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition ge(org.jooq.QuantifiedSelect> arg2); + /** * The GREATER_OR_EQUAL operator, an alias for the GE operator. */ @@ -723,6 +744,13 @@ extends @Support Condition greaterOrEqual(Field arg2); + /** + * The GREATER_OR_EQUAL operator, an alias for the GE operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition greaterOrEqual(org.jooq.QuantifiedSelect> arg2); + /** * The GREATER_THAN operator, an alias for the GT operator. */ @@ -744,6 +772,13 @@ extends @Support Condition greaterThan(Field arg2); + /** + * The GREATER_THAN operator, an alias for the GT operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition greaterThan(org.jooq.QuantifiedSelect> arg2); + /** * The GT operator. */ @@ -765,6 +800,13 @@ extends @Support Condition gt(Field arg2); + /** + * The GT operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition gt(org.jooq.QuantifiedSelect> arg2); + /** * The IN operator. *

@@ -871,6 +913,13 @@ extends @Support Condition le(Field arg2); + /** + * The LE operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition le(org.jooq.QuantifiedSelect> arg2); + /** * The LESS_OR_EQUAL operator, an alias for the LE operator. */ @@ -892,6 +941,13 @@ extends @Support Condition lessOrEqual(Field arg2); + /** + * The LESS_OR_EQUAL operator, an alias for the LE operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition lessOrEqual(org.jooq.QuantifiedSelect> arg2); + /** * The LESS_THAN operator, an alias for the LT operator. */ @@ -913,6 +969,13 @@ extends @Support Condition lessThan(Field arg2); + /** + * The LESS_THAN operator, an alias for the LT operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition lessThan(org.jooq.QuantifiedSelect> arg2); + /** * The LIKE operator. * @@ -929,6 +992,13 @@ extends @Support LikeEscapeStep like(Field pattern); + /** + * The LIKE operator. + */ + @NotNull + @Support + LikeEscapeStep like(org.jooq.QuantifiedSelect> pattern); + /** * The LIKE_IGNORE_CASE operator. *

@@ -980,6 +1050,13 @@ extends @Support Condition lt(Field arg2); + /** + * The LT operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition lt(org.jooq.QuantifiedSelect> arg2); + /** * The NE operator. */ @@ -1001,6 +1078,13 @@ extends @Support Condition ne(Field arg2); + /** + * The NE operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition ne(org.jooq.QuantifiedSelect> arg2); + /** * The NOT_EQUAL operator, an alias for the NE operator. */ @@ -1022,6 +1106,13 @@ extends @Support Condition notEqual(Field arg2); + /** + * The NOT_EQUAL operator, an alias for the NE operator. + */ + @NotNull + @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) + Condition notEqual(org.jooq.QuantifiedSelect> arg2); + /** * The NOT_IN operator. *

@@ -1053,6 +1144,13 @@ extends @Support LikeEscapeStep notLike(Field pattern); + /** + * The NOT_LIKE operator. + */ + @NotNull + @Support + LikeEscapeStep notLike(org.jooq.QuantifiedSelect> pattern); + /** * The NOT_LIKE_IGNORE_CASE operator. *

@@ -1099,6 +1197,13 @@ extends @Support LikeEscapeStep notSimilarTo(Field pattern); + /** + * The NOT_SIMILAR_TO operator. + */ + @NotNull + @Support + LikeEscapeStep notSimilarTo(org.jooq.QuantifiedSelect> pattern); + /** * The SIMILAR_TO operator. * @@ -1115,6 +1220,13 @@ extends @Support LikeEscapeStep similarTo(Field pattern); + /** + * The SIMILAR_TO operator. + */ + @NotNull + @Support + LikeEscapeStep similarTo(org.jooq.QuantifiedSelect> pattern); + // ------------------------------------------------------------------------- // XML predicates // ------------------------------------------------------------------------- @@ -2174,26 +2286,6 @@ extends @Support Condition like(String value, char escape); - /** - * Create a condition to pattern-check this field against a quantified select. - *

- * For example a query like {@code field.like(any("a%", "b%"))} translates into - * the SQL {@code (field like 'a%' or field like 'b%')}. - * - * @see DSL#all(Field) - * @see DSL#all(Field...) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Field...) - * @see DSL#any(Select) - * @see DSL#any(Object...) - * @see LikeEscapeStep#escape(char) - */ - @NotNull - @Support - LikeEscapeStep like(QuantifiedSelect> query); - /** * Create a condition to case-insensitively pattern-check this field against * a field. @@ -2244,26 +2336,6 @@ extends @Support Condition notLike(String value, char escape); - /** - * Create a condition to pattern-check this field against a quantified select. - *

- * For example a query like {@code field.notLike(any("a%", "b%"))} translates into - * the SQL {@code (field not like 'a%' or field not like 'b%')}. - * - * @see DSL#all(Field) - * @see DSL#all(Field...) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Field...) - * @see DSL#any(Select) - * @see DSL#any(Object...) - * @see LikeEscapeStep#escape(char) - */ - @NotNull - @Support - LikeEscapeStep notLike(QuantifiedSelect> query); - /** * Create a condition to case-insensitively pattern-check this field against * a field. @@ -2725,174 +2797,6 @@ extends // Comparison predicates // ------------------------------------------------------------------------ - /** - * this = [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition equal(QuantifiedSelect> query); - - /** - * this = [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition eq(QuantifiedSelect> query); - - /** - * this != [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition notEqual(QuantifiedSelect> query); - - /** - * this != [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition ne(QuantifiedSelect> query); - - /** - * this < [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition lessThan(QuantifiedSelect> query); - - /** - * this < [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition lt(QuantifiedSelect> query); - - /** - * this <= [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition lessOrEqual(QuantifiedSelect> query); - - /** - * this <= [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition le(QuantifiedSelect> query); - - /** - * this > [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition greaterThan(QuantifiedSelect> query); - - /** - * this > [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition gt(QuantifiedSelect> query); - - /** - * this >= [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition greaterOrEqual(QuantifiedSelect> query); - - /** - * this >= [quantifier] (Select<?> …). - * - * @see DSL#all(Field) - * @see DSL#all(Select) - * @see DSL#all(Object...) - * @see DSL#any(Field) - * @see DSL#any(Select) - * @see DSL#any(Object...) - */ - @NotNull - @Support({ CUBRID, DERBY, FIREBIRD, H2, HSQLDB, MARIADB, MYSQL, POSTGRES, YUGABYTEDB }) - Condition ge(QuantifiedSelect> query); - /** * Create a condition to check this field against known string literals for * true. diff --git a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java index d6227b9a7b..53597bd8c4 100644 --- a/jOOQ/src/main/java/org/jooq/impl/AbstractField.java +++ b/jOOQ/src/main/java/org/jooq/impl/AbstractField.java @@ -415,6 +415,11 @@ implements return new Eq<>(this, nullSafe(arg2, getDataType())); } + @Override + public final Condition eq(org.jooq.QuantifiedSelect> arg2) { + return new EqQuantified<>(this, arg2); + } + @Override public final Condition equal(T arg2) { return eq(arg2); @@ -430,6 +435,11 @@ implements return eq(arg2); } + @Override + public final Condition equal(org.jooq.QuantifiedSelect> arg2) { + return eq(arg2); + } + @Override public final Condition ge(T arg2) { return new Ge<>(this, Tools.field(arg2, this)); @@ -445,6 +455,11 @@ implements return new Ge<>(this, nullSafe(arg2, getDataType())); } + @Override + public final Condition ge(org.jooq.QuantifiedSelect> arg2) { + return new GeQuantified<>(this, arg2); + } + @Override public final Condition greaterOrEqual(T arg2) { return ge(arg2); @@ -460,6 +475,11 @@ implements return ge(arg2); } + @Override + public final Condition greaterOrEqual(org.jooq.QuantifiedSelect> arg2) { + return ge(arg2); + } + @Override public final Condition greaterThan(T arg2) { return gt(arg2); @@ -475,6 +495,11 @@ implements return gt(arg2); } + @Override + public final Condition greaterThan(org.jooq.QuantifiedSelect> arg2) { + return gt(arg2); + } + @Override public final Condition gt(T arg2) { return new Gt<>(this, Tools.field(arg2, this)); @@ -490,6 +515,11 @@ implements return new Gt<>(this, nullSafe(arg2, getDataType())); } + @Override + public final Condition gt(org.jooq.QuantifiedSelect> arg2) { + return new GtQuantified<>(this, arg2); + } + @Override public final Condition in(Select> arg2) { return new In<>(this, arg2); @@ -550,6 +580,11 @@ implements return new Le<>(this, nullSafe(arg2, getDataType())); } + @Override + public final Condition le(org.jooq.QuantifiedSelect> arg2) { + return new LeQuantified<>(this, arg2); + } + @Override public final Condition lessOrEqual(T arg2) { return le(arg2); @@ -565,6 +600,11 @@ implements return le(arg2); } + @Override + public final Condition lessOrEqual(org.jooq.QuantifiedSelect> arg2) { + return le(arg2); + } + @Override public final Condition lessThan(T arg2) { return lt(arg2); @@ -580,6 +620,11 @@ implements return lt(arg2); } + @Override + public final Condition lessThan(org.jooq.QuantifiedSelect> arg2) { + return lt(arg2); + } + @Override public final LikeEscapeStep like(String pattern) { return new Like(this, Tools.field(pattern)); @@ -590,6 +635,11 @@ implements return new Like(this, nullSafe(pattern, getDataType())); } + @Override + public final LikeEscapeStep like(org.jooq.QuantifiedSelect> pattern) { + return new LikeQuantified(this, pattern); + } + @Override public final LikeEscapeStep likeIgnoreCase(String pattern) { return new LikeIgnoreCase(this, Tools.field(pattern)); @@ -615,6 +665,11 @@ implements return new Lt<>(this, nullSafe(arg2, getDataType())); } + @Override + public final Condition lt(org.jooq.QuantifiedSelect> arg2) { + return new LtQuantified<>(this, arg2); + } + @Override public final Condition ne(T arg2) { return new Ne<>(this, Tools.field(arg2, this)); @@ -630,6 +685,11 @@ implements return new Ne<>(this, nullSafe(arg2, getDataType())); } + @Override + public final Condition ne(org.jooq.QuantifiedSelect> arg2) { + return new NeQuantified<>(this, arg2); + } + @Override public final Condition notEqual(T arg2) { return ne(arg2); @@ -645,6 +705,11 @@ implements return ne(arg2); } + @Override + public final Condition notEqual(org.jooq.QuantifiedSelect> arg2) { + return ne(arg2); + } + @Override public final Condition notIn(Select> arg2) { return new NotIn<>(this, arg2); @@ -660,6 +725,11 @@ implements return new NotLike(this, nullSafe(pattern, getDataType())); } + @Override + public final LikeEscapeStep notLike(org.jooq.QuantifiedSelect> pattern) { + return new NotLikeQuantified(this, pattern); + } + @Override public final LikeEscapeStep notLikeIgnoreCase(String pattern) { return new NotLikeIgnoreCase(this, Tools.field(pattern)); @@ -680,6 +750,11 @@ implements return new NotSimilarTo(this, nullSafe(pattern, getDataType())); } + @Override + public final LikeEscapeStep notSimilarTo(org.jooq.QuantifiedSelect> pattern) { + return new NotSimilarToQuantified(this, pattern); + } + @Override public final LikeEscapeStep similarTo(String pattern) { return new SimilarTo(this, Tools.field(pattern)); @@ -690,6 +765,11 @@ implements return new SimilarTo(this, nullSafe(pattern, getDataType())); } + @Override + public final LikeEscapeStep similarTo(org.jooq.QuantifiedSelect> pattern) { + return new SimilarToQuantified(this, pattern); + } + // ------------------------------------------------------------------------- // XML predicates // ------------------------------------------------------------------------- @@ -1170,11 +1250,6 @@ implements return like(field).escape(escape); } - @Override - public final LikeEscapeStep like(QuantifiedSelect> query) { - return new QuantifiedComparisonCondition(query, this, LIKE); - } - @Override public final Condition likeIgnoreCase(String value, char escape) { return likeIgnoreCase(Tools.field(value), escape); @@ -1205,11 +1280,6 @@ implements return notLike(field).escape(escape); } - @Override - public final LikeEscapeStep notLike(QuantifiedSelect> query) { - return new QuantifiedComparisonCondition(query, this, NOT_LIKE); - } - @Override public final Condition notLikeIgnoreCase(String value, char escape) { return notLikeIgnoreCase(Tools.field(value), escape); @@ -1398,36 +1468,6 @@ implements return new BetweenCondition<>(this, nullSafe(minValue, getDataType()), true, true); } - @Override - public final Condition eq(QuantifiedSelect> query) { - return equal(query); - } - - @Override - public final Condition ne(QuantifiedSelect> query) { - return notEqual(query); - } - - @Override - public final Condition lt(QuantifiedSelect> query) { - return lessThan(query); - } - - @Override - public final Condition le(QuantifiedSelect> query) { - return lessOrEqual(query); - } - - @Override - public final Condition gt(QuantifiedSelect> query) { - return greaterThan(query); - } - - @Override - public final Condition ge(QuantifiedSelect> query) { - return greaterOrEqual(query); - } - @Override public final Condition equalIgnoreCase(String value) { return equalIgnoreCase(Tools.field(value)); @@ -1438,11 +1478,6 @@ implements return DSL.lower(castIfNeeded(this, String.class)).equal(DSL.lower(value)); } - @Override - public final Condition equal(QuantifiedSelect> query) { - return compare(EQUALS, query); - } - @Override public final Condition notEqualIgnoreCase(String value) { return notEqualIgnoreCase(Tools.field(value)); @@ -1453,31 +1488,6 @@ implements return DSL.lower(castIfNeeded(this, String.class)).notEqual(DSL.lower(value)); } - @Override - public final Condition notEqual(QuantifiedSelect> query) { - return compare(NOT_EQUALS, query); - } - - @Override - public final Condition lessThan(QuantifiedSelect> query) { - return compare(LESS, query); - } - - @Override - public final Condition lessOrEqual(QuantifiedSelect> query) { - return compare(LESS_OR_EQUAL, query); - } - - @Override - public final Condition greaterThan(QuantifiedSelect> query) { - return compare(GREATER, query); - } - - @Override - public final Condition greaterOrEqual(QuantifiedSelect> query) { - return compare(GREATER_OR_EQUAL, query); - } - @Override public final Condition compare(Comparator comparator, T value) { return compare(comparator, Tools.field(value, this)); @@ -1541,7 +1551,30 @@ implements @Override public final Condition compare(Comparator comparator, QuantifiedSelect> query) { - return new QuantifiedComparisonCondition(query, this, comparator); + switch (comparator) { + case EQUALS: + return new EqQuantified<>(this, query); + case GREATER: + return new GtQuantified<>(this, query); + case GREATER_OR_EQUAL: + return new GeQuantified<>(this, query); + case LESS: + return new LtQuantified<>(this, query); + case LESS_OR_EQUAL: + return new LeQuantified<>(this, query); + case NOT_EQUALS: + return new NeQuantified<>(this, query); + case LIKE: + return new LikeQuantified(this, (QuantifiedSelect) query); + case NOT_LIKE: + return new NotLikeQuantified(this, (QuantifiedSelect) query); + case SIMILAR_TO: + return new SimilarToQuantified(this, (QuantifiedSelect) query); + case NOT_SIMILAR_TO: + return new NotSimilarToQuantified(this, (QuantifiedSelect) query); + } + + throw new IllegalArgumentException("Comparator not supported: " + comparator); } // ------------------------------------------------------------------------ diff --git a/jOOQ/src/main/java/org/jooq/impl/Array.java b/jOOQ/src/main/java/org/jooq/impl/Array.java index 56988f649c..5d9120768d 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Array.java +++ b/jOOQ/src/main/java/org/jooq/impl/Array.java @@ -121,7 +121,7 @@ final class Array extends AbstractField implements QOM.Array { @Override public final UnmodifiableList> $elements() { - return (UnmodifiableList>) QOM.unmodifiable(fields.fields); + return (UnmodifiableList) QOM.unmodifiable(fields.fields); } diff --git a/jOOQ/src/main/java/org/jooq/impl/EqQuantified.java b/jOOQ/src/main/java/org/jooq/impl/EqQuantified.java new file mode 100644 index 0000000000..c6fd0e86ba --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/EqQuantified.java @@ -0,0 +1,402 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The EQ statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class EqQuantified +extends + AbstractCondition +implements + QOM.EqQuantified +{ + + final Field arg1; + final org.jooq.QuantifiedSelect> arg2; + + EqQuantified( + Field arg1, + org.jooq.QuantifiedSelect> arg2 + ) { + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = arg2; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + private static final Set NO_SUPPORT_QUANTIFIED_LIKE = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, SQLITE); + private static final Set NO_SUPPORT_QUANTIFIED_SIMILAR_TO = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB); + private static final Set SUPPORTS_QUANTIFIED_ARRAYS = SQLDialect.supportedBy(POSTGRES); + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, arg1, org.jooq.Comparator.EQUALS, arg2); + } + + /** + * @deprecated - [#12425] After the QOM refactoring, this should be improved + */ + @Deprecated + static final void acceptCompareCondition( + Context ctx, + AbstractCondition condition, + Field arg1, + org.jooq.Comparator op, + org.jooq.QuantifiedSelect> arg2 + ) { + acceptCompareCondition(ctx, condition, arg1, op, arg2, null); + } + + /** + * @deprecated - [#12425] After the QOM refactoring, this should be improved + */ + @Deprecated + static final void acceptCompareCondition( + Context ctx, + AbstractCondition condition, + Field arg1, + org.jooq.Comparator op, + org.jooq.QuantifiedSelect> arg2, + Character escape + ) { + SelectQueryImpl s; + + if (arg1.getDataType().isEmbeddable()) { + ctx.visit(row(embeddedFields(arg1)).compare(op, arg2)); + } + else if ((op == org.jooq.Comparator.EQUALS || op == org.jooq.Comparator.NOT_EQUALS) + && (arg2 instanceof QOM.QuantifiedSelect) + && (s = Transformations.subqueryWithLimit(((QOM.QuantifiedSelect) arg2).$query())) != null + && Transformations.transformInConditionSubqueryWithLimitToDerivedTable(ctx.configuration())) { + + + + + + + } + + + + + + + + + + + else { + boolean quantifiedArrayParam = arg2 instanceof QOM.QuantifiedArray a ? a.$arg2() instanceof Param : false; + boolean quantifiedArray = arg2 instanceof QOM.QuantifiedArray a ? a.$arg2() instanceof Array : false; + boolean emulateOperator; + + switch (op) { + case LIKE: + case NOT_LIKE: + case LIKE_IGNORE_CASE: + case NOT_LIKE_IGNORE_CASE: + emulateOperator = escape != null || NO_SUPPORT_QUANTIFIED_LIKE.contains(ctx.dialect()); + break; + case SIMILAR_TO: + case NOT_SIMILAR_TO: + emulateOperator = escape != null || NO_SUPPORT_QUANTIFIED_SIMILAR_TO.contains(ctx.dialect()); + break; + default: + emulateOperator = false; + break; + } + + // [#9224] Special case when a SQL dialect actually supports quantified + // arrays, such as x = any(?::int[]) in PostgreSQL + if (quantifiedArrayParam && SUPPORTS_QUANTIFIED_ARRAYS.contains(ctx.dialect()) && !emulateOperator) { + accept1(ctx, arg1, op, arg2); + } + else if (quantifiedArrayParam || quantifiedArray) { + QOM.QuantifiedArray a = (org.jooq.impl.QOM.QuantifiedArray) arg2; + ctx.visit(DSL.condition( + a.$quantifier() == Quantifier.ALL ? org.jooq.Operator.AND : org.jooq.Operator.OR, + a.$array() instanceof Array + ? map(((Array) a.$array()).$elements(), v -> comparisonCondition(arg1, op, (Field) v, escape)) + : map(((Param) a.$array()).getValue(), v -> v instanceof Field ? comparisonCondition(arg1, op, (Field) v, escape) : comparisonCondition(arg1, op, v, escape)) + )); + } + else if (emulateOperator) { + Field pattern = DSL.field(name("pattern"), VARCHAR); + Condition c; + Field lhs; + + switch (op) { + case NOT_LIKE: + case NOT_SIMILAR_TO: + case NOT_LIKE_IGNORE_CASE: + c = comparisonCondition(arg1, inverse(op), pattern, escape); + lhs = inline(false); + break; + case LIKE: + case SIMILAR_TO: + case LIKE_IGNORE_CASE: + c = comparisonCondition(arg1, op, pattern, escape); + lhs = inline(true); + break; + default: + throw new IllegalStateException(); + } + + Table t; + Quantifier q; + + if (arg2 instanceof QuantifiedArray a) { + t = new ArrayTable(a.$array()).asTable("t", "pattern"); + q = a.$quantifier(); + } + else { + QOM.QuantifiedSelect qs = (QOM.QuantifiedSelect) arg2; + t = new AliasedSelect<>(qs.$query(), true, true, false, name("pattern")).as("t"); + q = qs.$quantifier(); + } + + ctx.visit(lhs.eq(quantify(q, select(c).from(t)))); + } + else + accept1(ctx, arg1, op, arg2); + } + } + + private static final void accept1( + Context ctx, + Field arg1, + org.jooq.Comparator op, + org.jooq.QuantifiedSelect arg2 + ) { + switch (ctx.family()) { + + + + + + + + + default: + ctx.visit(arg1) + .sql(' ') + .visit(op.toKeyword()) + .sql(' ') + .visit(arg2); + + break; + } + } + + private static final org.jooq.Comparator inverse(org.jooq.Comparator operator) { + switch (operator) { + case IN: return org.jooq.Comparator.NOT_IN; + case NOT_IN: return org.jooq.Comparator.IN; + case EQUALS: return org.jooq.Comparator.NOT_EQUALS; + case NOT_EQUALS: return org.jooq.Comparator.EQUALS; + case LESS: return org.jooq.Comparator.GREATER_OR_EQUAL; + case LESS_OR_EQUAL: return org.jooq.Comparator.GREATER; + case GREATER: return org.jooq.Comparator.LESS_OR_EQUAL; + case GREATER_OR_EQUAL: return org.jooq.Comparator.LESS; + case IS_DISTINCT_FROM: return org.jooq.Comparator.IS_NOT_DISTINCT_FROM; + case IS_NOT_DISTINCT_FROM: return org.jooq.Comparator.IS_DISTINCT_FROM; + case LIKE: return org.jooq.Comparator.NOT_LIKE; + case NOT_LIKE: return org.jooq.Comparator.LIKE; + case SIMILAR_TO: return org.jooq.Comparator.NOT_SIMILAR_TO; + case NOT_SIMILAR_TO: return org.jooq.Comparator.SIMILAR_TO; + case LIKE_IGNORE_CASE: return org.jooq.Comparator.NOT_LIKE_IGNORE_CASE; + case NOT_LIKE_IGNORE_CASE: return org.jooq.Comparator.LIKE_IGNORE_CASE; + default: throw new IllegalStateException(); + } + } + + private static final Condition comparisonCondition( + Field arg1, + org.jooq.Comparator op, + Field arg2, + Character escape + ) { + switch (op) { + case LIKE: + return escape != null ? arg1.like(arg2, escape) : arg1.like(arg2); + + case NOT_LIKE: + return escape != null ? arg1.notLike(arg2, escape) : arg1.notLike(arg2); + + case SIMILAR_TO: + return escape != null ? arg1.similarTo(arg2, escape) : arg1.similarTo(arg2); + + case NOT_SIMILAR_TO: + return escape != null ? arg1.notSimilarTo(arg2, escape) : arg1.notSimilarTo(arg2); + + case LIKE_IGNORE_CASE: + return escape != null ? arg1.likeIgnoreCase(arg2, escape) : arg1.likeIgnoreCase(arg2); + + case NOT_LIKE_IGNORE_CASE: + return escape != null ? arg1.notLikeIgnoreCase(arg2, escape) : arg1.notLikeIgnoreCase(arg2); + + default: + return ((Field) arg1).compare(op, arg2); + } + } + + @SuppressWarnings({ "unchecked", "rawtypes" }) + private static final Condition comparisonCondition( + Field arg1, + org.jooq.Comparator op, + Object arg2, + Character escape + ) { + switch (op) { + case LIKE: + return escape != null ? arg1.like(Convert.convert(arg2, String.class), escape) : arg1.like(Convert.convert(arg2, String.class)); + + case NOT_LIKE: + return escape != null ? arg1.notLike(Convert.convert(arg2, String.class), escape) : arg1.notLike(Convert.convert(arg2, String.class)); + + case SIMILAR_TO: + return escape != null ? arg1.similarTo(Convert.convert(arg2, String.class), escape) : arg1.similarTo(Convert.convert(arg2, String.class)); + + case NOT_SIMILAR_TO: + return escape != null ? arg1.notSimilarTo(Convert.convert(arg2, String.class), escape) : arg1.notSimilarTo(Convert.convert(arg2, String.class)); + + case LIKE_IGNORE_CASE: + return escape != null ? arg1.likeIgnoreCase(Convert.convert(arg2, String.class), escape) : arg1.likeIgnoreCase(Convert.convert(arg2, String.class)); + + case NOT_LIKE_IGNORE_CASE: + return escape != null ? arg1.notLikeIgnoreCase(Convert.convert(arg2, String.class), escape) : arg1.notLikeIgnoreCase(Convert.convert(arg2, String.class)); + + default: + return ((Field) arg1).compare(op, arg2); + } + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return arg2; + } + + @Override + public final QOM.EqQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.EqQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super org.jooq.QuantifiedSelect>, ? extends QOM.EqQuantified> $constructor() { + return (a1, a2) -> new EqQuantified<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.EqQuantified o) { + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/GeQuantified.java b/jOOQ/src/main/java/org/jooq/impl/GeQuantified.java new file mode 100644 index 0000000000..697f690738 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/GeQuantified.java @@ -0,0 +1,160 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The GE statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class GeQuantified +extends + AbstractCondition +implements + QOM.GeQuantified +{ + + final Field arg1; + final org.jooq.QuantifiedSelect> arg2; + + GeQuantified( + Field arg1, + org.jooq.QuantifiedSelect> arg2 + ) { + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = arg2; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, arg1, org.jooq.Comparator.GREATER_OR_EQUAL, arg2); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return arg2; + } + + @Override + public final QOM.GeQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.GeQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super org.jooq.QuantifiedSelect>, ? extends QOM.GeQuantified> $constructor() { + return (a1, a2) -> new GeQuantified<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.GeQuantified o) { + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/GtQuantified.java b/jOOQ/src/main/java/org/jooq/impl/GtQuantified.java new file mode 100644 index 0000000000..6b92d75964 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/GtQuantified.java @@ -0,0 +1,160 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The GT statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class GtQuantified +extends + AbstractCondition +implements + QOM.GtQuantified +{ + + final Field arg1; + final org.jooq.QuantifiedSelect> arg2; + + GtQuantified( + Field arg1, + org.jooq.QuantifiedSelect> arg2 + ) { + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = arg2; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, arg1, org.jooq.Comparator.GREATER, arg2); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return arg2; + } + + @Override + public final QOM.GtQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.GtQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super org.jooq.QuantifiedSelect>, ? extends QOM.GtQuantified> $constructor() { + return (a1, a2) -> new GtQuantified<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.GtQuantified o) { + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/LeQuantified.java b/jOOQ/src/main/java/org/jooq/impl/LeQuantified.java new file mode 100644 index 0000000000..884b11eade --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/LeQuantified.java @@ -0,0 +1,160 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The LE statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class LeQuantified +extends + AbstractCondition +implements + QOM.LeQuantified +{ + + final Field arg1; + final org.jooq.QuantifiedSelect> arg2; + + LeQuantified( + Field arg1, + org.jooq.QuantifiedSelect> arg2 + ) { + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = arg2; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, arg1, org.jooq.Comparator.LESS_OR_EQUAL, arg2); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return arg2; + } + + @Override + public final QOM.LeQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.LeQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super org.jooq.QuantifiedSelect>, ? extends QOM.LeQuantified> $constructor() { + return (a1, a2) -> new LeQuantified<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.LeQuantified o) { + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/LikeQuantified.java b/jOOQ/src/main/java/org/jooq/impl/LikeQuantified.java new file mode 100644 index 0000000000..f16d840c31 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/LikeQuantified.java @@ -0,0 +1,197 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.EqQuantified; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The LIKE statement. + */ +@SuppressWarnings({ "hiding", "rawtypes", "unused" }) +final class LikeQuantified +extends + AbstractCondition +implements + QOM.LikeQuantified, + LikeEscapeStep +{ + + final Field value; + final org.jooq.QuantifiedSelect> pattern; + Character escape; + + LikeQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern + ) { + this( + value, + pattern, + null + ); + } + + LikeQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern, + Character escape + ) { + + this.value = nullSafeNotNull(value, OTHER); + this.pattern = pattern; + this.escape = escape; + } + + // ------------------------------------------------------------------------- + // XXX: DSL API + // ------------------------------------------------------------------------- + + @Override + public final LikeQuantified escape(char escape) { + this.escape = escape; + return this; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, (Field) value, org.jooq.Comparator.LIKE, pattern, escape); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return value; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return pattern; + } + + @Override + public final Character $arg3() { + return escape; + } + + @Override + public final QOM.LikeQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2(), $arg3()); + } + + @Override + public final QOM.LikeQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue, $arg3()); + } + + @Override + public final QOM.LikeQuantified $arg3(Character newValue) { + return $constructor().apply($arg1(), $arg2(), newValue); + } + + @Override + public final Function3, ? super org.jooq.QuantifiedSelect>, ? super Character, ? extends QOM.LikeQuantified> $constructor() { + return (a1, a2, a3) -> new LikeQuantified(a1, a2, a3); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.LikeQuantified o) { + return + StringUtils.equals($value(), o.$value()) && + StringUtils.equals($pattern(), o.$pattern()) && + StringUtils.equals($escape(), o.$escape()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/LtQuantified.java b/jOOQ/src/main/java/org/jooq/impl/LtQuantified.java new file mode 100644 index 0000000000..ec524918b0 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/LtQuantified.java @@ -0,0 +1,160 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The LT statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class LtQuantified +extends + AbstractCondition +implements + QOM.LtQuantified +{ + + final Field arg1; + final org.jooq.QuantifiedSelect> arg2; + + LtQuantified( + Field arg1, + org.jooq.QuantifiedSelect> arg2 + ) { + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = arg2; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, arg1, org.jooq.Comparator.LESS, arg2); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return arg2; + } + + @Override + public final QOM.LtQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.LtQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super org.jooq.QuantifiedSelect>, ? extends QOM.LtQuantified> $constructor() { + return (a1, a2) -> new LtQuantified<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.LtQuantified o) { + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/NeQuantified.java b/jOOQ/src/main/java/org/jooq/impl/NeQuantified.java new file mode 100644 index 0000000000..aa058476a9 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/NeQuantified.java @@ -0,0 +1,160 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The NE statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class NeQuantified +extends + AbstractCondition +implements + QOM.NeQuantified +{ + + final Field arg1; + final org.jooq.QuantifiedSelect> arg2; + + NeQuantified( + Field arg1, + org.jooq.QuantifiedSelect> arg2 + ) { + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = arg2; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, arg1, org.jooq.Comparator.NOT_EQUALS, arg2); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return arg2; + } + + @Override + public final QOM.NeQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.NeQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super org.jooq.QuantifiedSelect>, ? extends QOM.NeQuantified> $constructor() { + return (a1, a2) -> new NeQuantified<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.NeQuantified o) { + return + StringUtils.equals($arg1(), o.$arg1()) && + StringUtils.equals($arg2(), o.$arg2()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/NotLikeQuantified.java b/jOOQ/src/main/java/org/jooq/impl/NotLikeQuantified.java new file mode 100644 index 0000000000..76b83fbd31 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/NotLikeQuantified.java @@ -0,0 +1,197 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.EqQuantified; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The NOT LIKE statement. + */ +@SuppressWarnings({ "hiding", "rawtypes", "unused" }) +final class NotLikeQuantified +extends + AbstractCondition +implements + QOM.NotLikeQuantified, + LikeEscapeStep +{ + + final Field value; + final org.jooq.QuantifiedSelect> pattern; + Character escape; + + NotLikeQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern + ) { + this( + value, + pattern, + null + ); + } + + NotLikeQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern, + Character escape + ) { + + this.value = nullSafeNotNull(value, OTHER); + this.pattern = pattern; + this.escape = escape; + } + + // ------------------------------------------------------------------------- + // XXX: DSL API + // ------------------------------------------------------------------------- + + @Override + public final NotLikeQuantified escape(char escape) { + this.escape = escape; + return this; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, (Field) value, org.jooq.Comparator.NOT_LIKE, pattern, escape); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return value; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return pattern; + } + + @Override + public final Character $arg3() { + return escape; + } + + @Override + public final QOM.NotLikeQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2(), $arg3()); + } + + @Override + public final QOM.NotLikeQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue, $arg3()); + } + + @Override + public final QOM.NotLikeQuantified $arg3(Character newValue) { + return $constructor().apply($arg1(), $arg2(), newValue); + } + + @Override + public final Function3, ? super org.jooq.QuantifiedSelect>, ? super Character, ? extends QOM.NotLikeQuantified> $constructor() { + return (a1, a2, a3) -> new NotLikeQuantified(a1, a2, a3); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.NotLikeQuantified o) { + return + StringUtils.equals($value(), o.$value()) && + StringUtils.equals($pattern(), o.$pattern()) && + StringUtils.equals($escape(), o.$escape()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/NotSimilarToQuantified.java b/jOOQ/src/main/java/org/jooq/impl/NotSimilarToQuantified.java new file mode 100644 index 0000000000..de9ccdd9f9 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/NotSimilarToQuantified.java @@ -0,0 +1,197 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.EqQuantified; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The NOT SIMILAR TO statement. + */ +@SuppressWarnings({ "hiding", "rawtypes", "unused" }) +final class NotSimilarToQuantified +extends + AbstractCondition +implements + QOM.NotSimilarToQuantified, + LikeEscapeStep +{ + + final Field value; + final org.jooq.QuantifiedSelect> pattern; + Character escape; + + NotSimilarToQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern + ) { + this( + value, + pattern, + null + ); + } + + NotSimilarToQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern, + Character escape + ) { + + this.value = nullSafeNotNull(value, OTHER); + this.pattern = pattern; + this.escape = escape; + } + + // ------------------------------------------------------------------------- + // XXX: DSL API + // ------------------------------------------------------------------------- + + @Override + public final NotSimilarToQuantified escape(char escape) { + this.escape = escape; + return this; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, (Field) value, org.jooq.Comparator.NOT_SIMILAR_TO, pattern, escape); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return value; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return pattern; + } + + @Override + public final Character $arg3() { + return escape; + } + + @Override + public final QOM.NotSimilarToQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2(), $arg3()); + } + + @Override + public final QOM.NotSimilarToQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue, $arg3()); + } + + @Override + public final QOM.NotSimilarToQuantified $arg3(Character newValue) { + return $constructor().apply($arg1(), $arg2(), newValue); + } + + @Override + public final Function3, ? super org.jooq.QuantifiedSelect>, ? super Character, ? extends QOM.NotSimilarToQuantified> $constructor() { + return (a1, a2, a3) -> new NotSimilarToQuantified(a1, a2, a3); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.NotSimilarToQuantified o) { + return + StringUtils.equals($value(), o.$value()) && + StringUtils.equals($pattern(), o.$pattern()) && + StringUtils.equals($escape(), o.$escape()) + ; + } + else + return super.equals(that); + } +} diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index 75dc7272b9..8931924bca 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -113,6 +113,7 @@ import org.jooq.Param; import org.jooq.Parameter; import org.jooq.Privilege; // ... +import org.jooq.QuantifiedSelect; import org.jooq.Query; import org.jooq.QueryPart; import org.jooq.Record; @@ -1050,7 +1051,6 @@ public final class QOM { @NotNull default QuantifiedArray $array(Field newArray) { return $arg2(newArray); } } - // ------------------------------------------------------------------------- // XXX: Rows // ------------------------------------------------------------------------- @@ -1569,6 +1569,12 @@ public final class QOM { ScalarSubquery*/ {} + public /*sealed*/ interface RowSubquery + extends + Row, + UOperator1, RowSubquery> + {} + public /*sealed*/ interface Neg extends UReturnsNullOnNullInput, @@ -2798,6 +2804,18 @@ public final class QOM { // Eq {} + /** + * The EQ operator. + */ + public /*sealed*/ interface EqQuantified + extends + UReturnsNullOnNullInput, + UOperator2, org.jooq.QuantifiedSelect>, EqQuantified>, + org.jooq.Condition + //permits + // EqQuantified + {} + /** * The EXISTS function. */ @@ -2830,6 +2848,18 @@ public final class QOM { } } + /** + * The GE operator. + */ + public /*sealed*/ interface GeQuantified + extends + UReturnsNullOnNullInput, + UOperator2, org.jooq.QuantifiedSelect>, GeQuantified>, + org.jooq.Condition + //permits + // GeQuantified + {} + /** * The GT operator. */ @@ -2847,6 +2877,18 @@ public final class QOM { } } + /** + * The GT operator. + */ + public /*sealed*/ interface GtQuantified + extends + UReturnsNullOnNullInput, + UOperator2, org.jooq.QuantifiedSelect>, GtQuantified>, + org.jooq.Condition + //permits + // GtQuantified + {} + /** * The IN operator. *

@@ -2937,6 +2979,18 @@ public final class QOM { } } + /** + * The LE operator. + */ + public /*sealed*/ interface LeQuantified + extends + UReturnsNullOnNullInput, + UOperator2, org.jooq.QuantifiedSelect>, LeQuantified>, + org.jooq.Condition + //permits + // LeQuantified + {} + /** * The LIKE operator. */ @@ -2959,6 +3013,28 @@ public final class QOM { @NotNull default Like $escape(Character newEscape) { return $arg3(newEscape); } } + /** + * The LIKE operator. + */ + public /*sealed*/ interface LikeQuantified + extends + UReturnsNullOnNullInput, + UOperator3, org.jooq.QuantifiedSelect>, Character, LikeQuantified>, + Condition + //permits + // LikeQuantified + { + @NotNull default Field $value() { return $arg1(); } + @CheckReturnValue + @NotNull default LikeQuantified $value(Field newValue) { return $arg1(newValue); } + @NotNull default org.jooq.QuantifiedSelect> $pattern() { return $arg2(); } + @CheckReturnValue + @NotNull default LikeQuantified $pattern(org.jooq.QuantifiedSelect> newPattern) { return $arg2(newPattern); } + @Nullable default Character $escape() { return $arg3(); } + @CheckReturnValue + @NotNull default LikeQuantified $escape(Character newEscape) { return $arg3(newEscape); } + } + /** * The LIKE IGNORE CASE operator. *

@@ -3005,6 +3081,18 @@ public final class QOM { } } + /** + * The LT operator. + */ + public /*sealed*/ interface LtQuantified + extends + UReturnsNullOnNullInput, + UOperator2, org.jooq.QuantifiedSelect>, LtQuantified>, + org.jooq.Condition + //permits + // LtQuantified + {} + /** * The NE operator. */ @@ -3029,6 +3117,18 @@ public final class QOM { // Ne {} + /** + * The NE operator. + */ + public /*sealed*/ interface NeQuantified + extends + UReturnsNullOnNullInput, + UOperator2, org.jooq.QuantifiedSelect>, NeQuantified>, + org.jooq.Condition + //permits + // NeQuantified + {} + /** * The NOT operator. */ @@ -3102,6 +3202,28 @@ public final class QOM { @NotNull default NotLike $escape(Character newEscape) { return $arg3(newEscape); } } + /** + * The NOT LIKE operator. + */ + public /*sealed*/ interface NotLikeQuantified + extends + UReturnsNullOnNullInput, + UOperator3, org.jooq.QuantifiedSelect>, Character, NotLikeQuantified>, + Condition + //permits + // NotLikeQuantified + { + @NotNull default Field $value() { return $arg1(); } + @CheckReturnValue + @NotNull default NotLikeQuantified $value(Field newValue) { return $arg1(newValue); } + @NotNull default org.jooq.QuantifiedSelect> $pattern() { return $arg2(); } + @CheckReturnValue + @NotNull default NotLikeQuantified $pattern(org.jooq.QuantifiedSelect> newPattern) { return $arg2(newPattern); } + @Nullable default Character $escape() { return $arg3(); } + @CheckReturnValue + @NotNull default NotLikeQuantified $escape(Character newEscape) { return $arg3(newEscape); } + } + /** * The NOT LIKE IGNORE CASE operator. *

@@ -3153,6 +3275,28 @@ public final class QOM { @NotNull default NotSimilarTo $escape(Character newEscape) { return $arg3(newEscape); } } + /** + * The NOT SIMILAR TO operator. + */ + public /*sealed*/ interface NotSimilarToQuantified + extends + UReturnsNullOnNullInput, + UOperator3, org.jooq.QuantifiedSelect>, Character, NotSimilarToQuantified>, + Condition + //permits + // NotSimilarToQuantified + { + @NotNull default Field $value() { return $arg1(); } + @CheckReturnValue + @NotNull default NotSimilarToQuantified $value(Field newValue) { return $arg1(newValue); } + @NotNull default org.jooq.QuantifiedSelect> $pattern() { return $arg2(); } + @CheckReturnValue + @NotNull default NotSimilarToQuantified $pattern(org.jooq.QuantifiedSelect> newPattern) { return $arg2(newPattern); } + @Nullable default Character $escape() { return $arg3(); } + @CheckReturnValue + @NotNull default NotSimilarToQuantified $escape(Character newEscape) { return $arg3(newEscape); } + } + /** * The OR operator. */ @@ -3186,6 +3330,28 @@ public final class QOM { @NotNull default SimilarTo $escape(Character newEscape) { return $arg3(newEscape); } } + /** + * The SIMILAR TO operator. + */ + public /*sealed*/ interface SimilarToQuantified + extends + UReturnsNullOnNullInput, + UOperator3, org.jooq.QuantifiedSelect>, Character, SimilarToQuantified>, + Condition + //permits + // SimilarToQuantified + { + @NotNull default Field $value() { return $arg1(); } + @CheckReturnValue + @NotNull default SimilarToQuantified $value(Field newValue) { return $arg1(newValue); } + @NotNull default org.jooq.QuantifiedSelect> $pattern() { return $arg2(); } + @CheckReturnValue + @NotNull default SimilarToQuantified $pattern(org.jooq.QuantifiedSelect> newPattern) { return $arg2(newPattern); } + @Nullable default Character $escape() { return $arg3(); } + @CheckReturnValue + @NotNull default SimilarToQuantified $escape(Character newEscape) { return $arg3(newEscape); } + } + /** * The UNIQUE function. */ diff --git a/jOOQ/src/main/java/org/jooq/impl/QuantifiedComparisonCondition.java b/jOOQ/src/main/java/org/jooq/impl/QuantifiedComparisonCondition.java deleted file mode 100644 index 5474201380..0000000000 --- a/jOOQ/src/main/java/org/jooq/impl/QuantifiedComparisonCondition.java +++ /dev/null @@ -1,343 +0,0 @@ -/* - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * https://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * Other licenses: - * ----------------------------------------------------------------------------- - * Commercial licenses for this work are available. These replace the above - * ASL 2.0 and offer limited warranties, support, maintenance, and commercial - * database integrations. - * - * For more information, please visit: https://www.jooq.org/legal/licensing - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - -package org.jooq.impl; - -import static org.jooq.Clause.CONDITION; -import static org.jooq.Clause.CONDITION_BETWEEN; -import static org.jooq.Comparator.EQUALS; -import static org.jooq.Comparator.NOT_EQUALS; -// ... -// ... -// ... -// ... -// ... -import static org.jooq.SQLDialect.CUBRID; -// ... -import static org.jooq.SQLDialect.DERBY; -import static org.jooq.SQLDialect.FIREBIRD; -import static org.jooq.SQLDialect.H2; -// ... -import static org.jooq.SQLDialect.HSQLDB; -import static org.jooq.SQLDialect.IGNITE; -// ... -// ... -// ... -import static org.jooq.SQLDialect.MARIADB; -// ... -import static org.jooq.SQLDialect.MYSQL; -// ... -import static org.jooq.SQLDialect.POSTGRES; -// ... -// ... -import static org.jooq.SQLDialect.SQLITE; -// ... -// ... -// ... -// ... -import static org.jooq.SQLDialect.YUGABYTEDB; -import static org.jooq.impl.DSL.asterisk; -import static org.jooq.impl.DSL.inline; -import static org.jooq.impl.DSL.name; -import static org.jooq.impl.DSL.row; -import static org.jooq.impl.DSL.select; -import static org.jooq.impl.SQLDataType.VARCHAR; -import static org.jooq.impl.Tools.characterLiteral; -import static org.jooq.impl.Tools.embeddedFields; -import static org.jooq.impl.Tools.map; -import static org.jooq.impl.Tools.quantify; -import static org.jooq.impl.Transformations.transformInConditionSubqueryWithLimitToDerivedTable; -import static org.jooq.impl.Transformations.subqueryWithLimit; -import static org.jooq.tools.Convert.convert; - -import java.util.Set; - -import org.jooq.Clause; -import org.jooq.Comparator; -import org.jooq.Condition; -import org.jooq.Context; -import org.jooq.Field; -import org.jooq.LikeEscapeStep; -import org.jooq.Operator; -import org.jooq.Param; -import org.jooq.QuantifiedSelect; -import org.jooq.Record1; -import org.jooq.SQLDialect; -import org.jooq.Select; -import org.jooq.Table; -import org.jooq.impl.QOM.Array; -import org.jooq.impl.QOM.Quantifier; -import org.jooq.impl.QOM.UNotYetImplemented; - -/** - * @author Lukas Eder - */ -final class QuantifiedComparisonCondition extends AbstractCondition implements LikeEscapeStep, UNotYetImplemented { - - private static final Clause[] CLAUSES = { CONDITION, CONDITION_BETWEEN }; - private static final Set NO_SUPPORT_QUANTIFIED_LIKE = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, SQLITE); - private static final Set NO_SUPPORT_QUANTIFIED_SIMILAR_TO = SQLDialect.supportedBy(CUBRID, DERBY, FIREBIRD, H2, HSQLDB, IGNITE, MARIADB, MYSQL, POSTGRES, SQLITE, YUGABYTEDB); - private static final Set SUPPORTS_QUANTIFIED_ARRAYS = SQLDialect.supportedBy(POSTGRES); - - private final QuantifiedSelect query; - private final Field field; - private final Comparator comparator; - private Character escape; - - QuantifiedComparisonCondition(QuantifiedSelect query, Field field, Comparator comparator) { - this.query = query; - this.field = field; - this.comparator = comparator; - } - - @Override - public Condition escape(char c) { - this.escape = c; - return this; - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public final void accept(Context ctx) { - SelectQueryImpl s; - - if (field.getDataType().isEmbeddable()) { - ctx.visit(row(embeddedFields(field)).compare(comparator, query)); - } - else if ((comparator == EQUALS || comparator == NOT_EQUALS) - && (query instanceof QOM.QuantifiedSelect) - && (s = subqueryWithLimit(((QOM.QuantifiedSelect) query).$query())) != null - && transformInConditionSubqueryWithLimitToDerivedTable(ctx.configuration())) { - - - - - - - } - - - - - - - - - - - else - accept0(ctx); - } - - private final void accept0(Context ctx) { - boolean quantifiedArrayParam = query instanceof QOM.QuantifiedArray a ? a.$arg2() instanceof Param : false; - boolean quantifiedArray = query instanceof QOM.QuantifiedArray a ? a.$arg2() instanceof Array : false; - boolean emulateOperator; - - switch (comparator) { - case LIKE: - case NOT_LIKE: - case LIKE_IGNORE_CASE: - case NOT_LIKE_IGNORE_CASE: - emulateOperator = escape != null || NO_SUPPORT_QUANTIFIED_LIKE.contains(ctx.dialect()); - break; - case SIMILAR_TO: - case NOT_SIMILAR_TO: - emulateOperator = escape != null || NO_SUPPORT_QUANTIFIED_SIMILAR_TO.contains(ctx.dialect()); - break; - default: - emulateOperator = false; - break; - } - - // [#9224] Special case when a SQL dialect actually supports quantified - // arrays, such as x = any(?::int[]) in PostgreSQL - if (quantifiedArrayParam && SUPPORTS_QUANTIFIED_ARRAYS.contains(ctx.dialect()) && !emulateOperator) { - accept1(ctx); - } - else if (quantifiedArrayParam || quantifiedArray) { - QOM.QuantifiedArray a = (org.jooq.impl.QOM.QuantifiedArray) query; - ctx.visit(DSL.condition( - a.$quantifier() == Quantifier.ALL ? Operator.AND : Operator.OR, - a.$array() instanceof Array - ? map(((Array) a.$array()).$elements(), v -> comparisonCondition(comparator, (Field) v)) - : map(((Param) a.$array()).getValue(), v -> v instanceof Field ? comparisonCondition(comparator, (Field) v) : comparisonCondition(comparator, v)) - )); - } - else if (emulateOperator) { - Field pattern = DSL.field(name("pattern"), VARCHAR); - Condition condition; - Field lhs; - - switch (comparator) { - case NOT_LIKE: - case NOT_SIMILAR_TO: - case NOT_LIKE_IGNORE_CASE: - condition = comparisonCondition(inverse(comparator), pattern); - lhs = inline(false); - break; - case LIKE: - case SIMILAR_TO: - case LIKE_IGNORE_CASE: - condition = comparisonCondition(comparator, pattern); - lhs = inline(true); - break; - default: - throw new IllegalStateException(); - } - - Table t; - Quantifier q; - - if (query instanceof QuantifiedArray a) { - t = new ArrayTable(a.$array()).asTable("t", "pattern"); - q = a.$quantifier(); - } - else { - QOM.QuantifiedSelect s = (QOM.QuantifiedSelect) query; - t = new AliasedSelect<>(s.$query(), true, true, false, name("pattern")).as("t"); - q = s.$quantifier(); - } - - ctx.visit(lhs.eq(quantify(q, select(condition).from(t)))); - } - else { - accept1(ctx); - } - } - - private final void accept1(Context ctx) { - switch (ctx.family()) { - - - - - - - - - default: - ctx.visit(field) - .sql(' ') - .visit(comparator.toKeyword()) - .sql(' ') - .visit(query); - - break; - } - } - - private Comparator inverse(Comparator operator) { - switch (operator) { - case IN: return Comparator.NOT_IN; - case NOT_IN: return Comparator.IN; - case EQUALS: return Comparator.NOT_EQUALS; - case NOT_EQUALS: return Comparator.EQUALS; - case LESS: return Comparator.GREATER_OR_EQUAL; - case LESS_OR_EQUAL: return Comparator.GREATER; - case GREATER: return Comparator.LESS_OR_EQUAL; - case GREATER_OR_EQUAL: return Comparator.LESS; - case IS_DISTINCT_FROM: return Comparator.IS_NOT_DISTINCT_FROM; - case IS_NOT_DISTINCT_FROM: return Comparator.IS_DISTINCT_FROM; - case LIKE: return Comparator.NOT_LIKE; - case NOT_LIKE: return Comparator.LIKE; - case SIMILAR_TO: return Comparator.NOT_SIMILAR_TO; - case NOT_SIMILAR_TO: return Comparator.SIMILAR_TO; - case LIKE_IGNORE_CASE: return Comparator.NOT_LIKE_IGNORE_CASE; - case NOT_LIKE_IGNORE_CASE: return Comparator.LIKE_IGNORE_CASE; - default: throw new IllegalStateException(); - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private Condition comparisonCondition(Comparator operator, Field value) { - switch (operator) { - case LIKE: - return escape != null ? field.like(value, escape) : field.like(value); - - case NOT_LIKE: - return escape != null ? field.notLike(value, escape) : field.notLike(value); - - case SIMILAR_TO: - return escape != null ? field.similarTo(value, escape) : field.similarTo(value); - - case NOT_SIMILAR_TO: - return escape != null ? field.notSimilarTo(value, escape) : field.notSimilarTo(value); - - case LIKE_IGNORE_CASE: - return escape != null ? field.likeIgnoreCase(value, escape) : field.likeIgnoreCase(value); - - case NOT_LIKE_IGNORE_CASE: - return escape != null ? field.notLikeIgnoreCase(value, escape) : field.notLikeIgnoreCase(value); - - default: - return ((Field) field).compare(operator, value); - } - } - - @SuppressWarnings({ "unchecked", "rawtypes" }) - private Condition comparisonCondition(Comparator operator, Object value) { - switch (operator) { - case LIKE: - return escape != null ? field.like(Convert.convert(value, String.class), escape) : field.like(Convert.convert(value, String.class)); - - case NOT_LIKE: - return escape != null ? field.notLike(Convert.convert(value, String.class), escape) : field.notLike(Convert.convert(value, String.class)); - - case SIMILAR_TO: - return escape != null ? field.similarTo(Convert.convert(value, String.class), escape) : field.similarTo(Convert.convert(value, String.class)); - - case NOT_SIMILAR_TO: - return escape != null ? field.notSimilarTo(Convert.convert(value, String.class), escape) : field.notSimilarTo(Convert.convert(value, String.class)); - - case LIKE_IGNORE_CASE: - return escape != null ? field.likeIgnoreCase(Convert.convert(value, String.class), escape) : field.likeIgnoreCase(Convert.convert(value, String.class)); - - case NOT_LIKE_IGNORE_CASE: - return escape != null ? field.notLikeIgnoreCase(Convert.convert(value, String.class), escape) : field.notLikeIgnoreCase(Convert.convert(value, String.class)); - - default: - return ((Field) field).compare(operator, value); - } - } - - @Override - public final Clause[] clauses(Context ctx) { - return CLAUSES; - } -} diff --git a/jOOQ/src/main/java/org/jooq/impl/SimilarToQuantified.java b/jOOQ/src/main/java/org/jooq/impl/SimilarToQuantified.java new file mode 100644 index 0000000000..dca14d6d48 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/SimilarToQuantified.java @@ -0,0 +1,197 @@ +/* + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * Other licenses: + * ----------------------------------------------------------------------------- + * Commercial licenses for this work are available. These replace the above + * ASL 2.0 and offer limited warranties, support, maintenance, and commercial + * database integrations. + * + * For more information, please visit: https://www.jooq.org/legal/licensing + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + */ +package org.jooq.impl; + +import static org.jooq.impl.DSL.*; +import static org.jooq.impl.Internal.*; +import static org.jooq.impl.Keywords.*; +import static org.jooq.impl.Names.*; +import static org.jooq.impl.SQLDataType.*; +import static org.jooq.impl.Tools.*; +import static org.jooq.impl.Tools.BooleanDataKey.*; +import static org.jooq.impl.Tools.ExtendedDataKey.*; +import static org.jooq.impl.Tools.SimpleDataKey.*; +import static org.jooq.SQLDialect.*; + +import org.jooq.*; +import org.jooq.Function1; +import org.jooq.Record; +import org.jooq.conf.*; +import org.jooq.impl.*; +import org.jooq.impl.EqQuantified; +import org.jooq.impl.QOM.*; +import org.jooq.tools.*; + +import java.util.*; +import java.util.function.*; +import java.util.stream.*; + + +/** + * The SIMILAR TO statement. + */ +@SuppressWarnings({ "hiding", "rawtypes", "unused" }) +final class SimilarToQuantified +extends + AbstractCondition +implements + QOM.SimilarToQuantified, + LikeEscapeStep +{ + + final Field value; + final org.jooq.QuantifiedSelect> pattern; + Character escape; + + SimilarToQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern + ) { + this( + value, + pattern, + null + ); + } + + SimilarToQuantified( + Field value, + org.jooq.QuantifiedSelect> pattern, + Character escape + ) { + + this.value = nullSafeNotNull(value, OTHER); + this.pattern = pattern; + this.escape = escape; + } + + // ------------------------------------------------------------------------- + // XXX: DSL API + // ------------------------------------------------------------------------- + + @Override + public final SimilarToQuantified escape(char escape) { + this.escape = escape; + return this; + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + + + @Override + public final void accept(Context ctx) { + + + + + + + + EqQuantified.acceptCompareCondition(ctx, this, (Field) value, org.jooq.Comparator.SIMILAR_TO, pattern, escape); + } + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return value; + } + + @Override + public final org.jooq.QuantifiedSelect> $arg2() { + return pattern; + } + + @Override + public final Character $arg3() { + return escape; + } + + @Override + public final QOM.SimilarToQuantified $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2(), $arg3()); + } + + @Override + public final QOM.SimilarToQuantified $arg2(org.jooq.QuantifiedSelect> newValue) { + return $constructor().apply($arg1(), newValue, $arg3()); + } + + @Override + public final QOM.SimilarToQuantified $arg3(Character newValue) { + return $constructor().apply($arg1(), $arg2(), newValue); + } + + @Override + public final Function3, ? super org.jooq.QuantifiedSelect>, ? super Character, ? extends QOM.SimilarToQuantified> $constructor() { + return (a1, a2, a3) -> new SimilarToQuantified(a1, a2, a3); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.SimilarToQuantified o) { + return + StringUtils.equals($value(), o.$value()) && + StringUtils.equals($pattern(), o.$pattern()) && + StringUtils.equals($escape(), o.$escape()) + ; + } + else + return super.equals(that); + } +}