From 6811484f8b110204ac2a68bc640c5185f86a0eae Mon Sep 17 00:00:00 2001 From: lukaseder Date: Thu, 20 Apr 2017 11:33:52 +0200 Subject: [PATCH] [#6108] Add PostgresDSL.arrayOverlap() --- .../org/jooq/util/postgres/PostgresDSL.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java index 7c9e0b1791..736ba47006 100644 --- a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java +++ b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java @@ -36,6 +36,7 @@ package org.jooq.util.postgres; import static org.jooq.SQLDialect.POSTGRES; +import org.jooq.Condition; import org.jooq.DataType; import org.jooq.Field; import org.jooq.Record; @@ -63,6 +64,54 @@ public class PostgresDSL extends DSL { // PostgreSQL-specific array functions // ------------------------------------------------------------------------- + /** + * The PostgreSQL array1 && array2 overlap operator. + *

+ * Example:

+     * true = array[1, 2, 3] && array[3, 4, 5]
+     * 
+ */ + @Support({ POSTGRES }) + public static Condition arrayOverlap(T[] left, T[] right) { + return arrayOverlap(val(left), val(right)); + } + + /** + * The PostgreSQL array1 && array2 overlap operator. + *

+ * Example:

+     * true = array[1, 2, 3] && array[3, 4, 5]
+     * 
+ */ + @Support({ POSTGRES }) + public static Condition arrayOverlap(T[] left, Field right) { + return arrayOverlap(val(left), right); + } + + /** + * The PostgreSQL array1 && array2 overlap operator. + *

+ * Example:

+     * true = array[1, 2, 3] && array[3, 4, 5]
+     * 
+ */ + @Support({ POSTGRES }) + public static Condition arrayOverlap(Field left, T[] right) { + return arrayOverlap(left, val(right)); + } + + /** + * The PostgreSQL array1 && array2 overlap operator. + *

+ * Example:

+     * true = array[1, 2, 3] && array[3, 4, 5]
+     * 
+ */ + @Support({ POSTGRES }) + public static Condition arrayOverlap(Field left, Field right) { + return DSL.condition("{0} && {1}", left, right); + } + /** * The PostgreSQL array(select) function. *