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 1466e1b72c..57e92ac938 100644 --- a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java +++ b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java @@ -225,6 +225,106 @@ public class PostgresDSL extends DSL { return field("{array_cat}({0}, {1})", nullSafe(array1).getDataType(), nullSafe(array1), nullSafe(array2)); } + /** + * The PostgreSQL array_remove(anyarray, anyelement) function. + *

+ * Example:

+     * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayRemove(T[] array, T element) { + return arrayRemove(val(array), val(element)); + } + + /** + * The PostgreSQL array_remove(anyarray, anyelement) function. + *

+ * Example:

+     * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayRemove(Field array, T element) { + return arrayRemove(nullSafe(array), val(element)); + } + + /** + * The PostgreSQL array_remove(anyarray, anyelement) function. + *

+ * Example:

+     * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayRemove(T[] array, Field element) { + return arrayRemove(val(array), nullSafe(element)); + } + + /** + * The PostgreSQL array_remove(anyarray, anyelement) function. + *

+ * Example:

+     * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayRemove(Field array, Field element) { + return field("{array_remove}({0}, {1})", array.getDataType(), array, element); + } + + /** + * The PostgreSQL + * array_replace(anyarray, anyelement, anyelement) function. + *

+ * Example:

+     * {1,2,3,4} = array_replace(ARRAY[1,2,5,4], 5, 3)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayReplace(T[] array, T search, T replace) { + return arrayReplace(val(array), val(search), val(replace)); + } + + /** + * The PostgreSQL + * array_replace(anyarray, anyelement, anyelement) function. + *

+ * Example:

+     * {1,2,3,4} = array_replace(ARRAY[1,2,5,4], 5, 3)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayReplace(T[] array, Field search, Field replace) { + return arrayReplace(val(array), nullSafe(search), nullSafe(replace)); + } + + /** + * The PostgreSQL + * array_replace(anyarray, anyelement, anyelement) function. + *

+ * Example:

+     * {1,2,3,4} = array_replace(ARRAY[1,2,5,4], 5, 3)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayReplace(Field array, T search, T replace) { + return arrayReplace(nullSafe(array), val(search), val(replace)); + } + + /** + * The PostgreSQL + * array_replace(anyarray, anyelement, anyelement) function. + *

+ * Example:

+     * {1,2,3,4} = array_replace(ARRAY[1,2,5,4], 5, 3)
+     * 
+ */ + @Support({ POSTGRES }) + public static Field arrayReplace(Field array, Field search, Field replace) { + return field("{array_replace}({0}, {1}, {2})", array.getDataType(), nullSafe(array), nullSafe(search), nullSafe(replace)); + } + /** * The PostgreSQL array_fill(anyelement, int[]) function. *