diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayRemove.java b/jOOQ/src/main/java/org/jooq/impl/ArrayRemove.java new file mode 100644 index 0000000000..7ef4c25493 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayRemove.java @@ -0,0 +1,172 @@ +/* + * 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 ARRAY REMOVE statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class ArrayRemove +extends + AbstractField +implements + QOM.ArrayRemove +{ + + final Field arg1; + final Field arg2; + + ArrayRemove( + Field arg1, + Field arg2 + ) { + super( + N_ARRAY_REMOVE, + allNotNull(((DataType) OTHER).getArrayDataType(), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, ((DataType) OTHER).getArrayDataType()); + this.arg2 = nullSafeNotNull(arg2, (DataType) OTHER); + } + + // ------------------------------------------------------------------------- + // XXX: QueryPart API + // ------------------------------------------------------------------------- + + @Override + final boolean parenthesised(Context ctx) { + return true; + } + + @Override + public final void accept(Context ctx) { + switch (ctx.family()) { + + + + + + + default: + ctx.visit(function(N_ARRAY_REMOVE, getDataType(), arg1, arg2)); + break; + } + } + + + + + + + + + + + + + + + // ------------------------------------------------------------------------- + // XXX: Query Object Model + // ------------------------------------------------------------------------- + + @Override + public final Field $arg1() { + return arg1; + } + + @Override + public final Field $arg2() { + return arg2; + } + + @Override + public final QOM.ArrayRemove $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.ArrayRemove $arg2(Field newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.ArrayRemove> $constructor() { + return (a1, a2) -> new ArrayRemove<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.ArrayRemove 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/DSL.java b/jOOQ/src/main/java/org/jooq/impl/DSL.java index 14cb28d300..e0a709c133 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -19780,6 +19780,54 @@ public class DSL { return new ArrayOverlap<>(arg1, arg2); } + /** + * The ARRAY_REMOVE function. + *

+ * Remove an element from an array. + * + * @param arg2 is wrapped as {@link #val(Object)}. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayRemove(T[] arg1, T arg2) { + return new ArrayRemove<>(Tools.field(arg1), Tools.field(arg2)); + } + + /** + * The ARRAY_REMOVE function. + *

+ * Remove an element from an array. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayRemove(T[] arg1, Field arg2) { + return new ArrayRemove<>(Tools.field(arg1), arg2); + } + + /** + * The ARRAY_REMOVE function. + *

+ * Remove an element from an array. + * + * @param arg2 is wrapped as {@link #val(Object)}. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayRemove(Field arg1, T arg2) { + return new ArrayRemove<>(arg1, Tools.field(arg2)); + } + + /** + * The ARRAY_REMOVE function. + *

+ * Remove an element from an array. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayRemove(Field arg1, Field arg2) { + return new ArrayRemove<>(arg1, arg2); + } + // ------------------------------------------------------------------------- // Utility functions // ------------------------------------------------------------------------- diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 66715b3fd9..5b0506d6ac 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -348,6 +348,7 @@ final class Names { static final Name N_ARRAY_CONCAT = systemName("array_concat"); static final Name N_ARRAY_GET = systemName("array_get"); static final Name N_ARRAY_OVERLAP = systemName("array_overlap"); + static final Name N_ARRAY_REMOVE = systemName("array_remove"); static final Name N_ASCII = systemName("ascii"); static final Name N_ASIN = systemName("asin"); static final Name N_ASINH = systemName("asinh"); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index ff90d85b69..a585364d57 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -81,6 +81,7 @@ import static org.jooq.impl.DSL.arrayAgg; import static org.jooq.impl.DSL.arrayAggDistinct; import static org.jooq.impl.DSL.arrayConcat; import static org.jooq.impl.DSL.arrayGet; +import static org.jooq.impl.DSL.arrayRemove; import static org.jooq.impl.DSL.ascii; import static org.jooq.impl.DSL.asin; import static org.jooq.impl.DSL.asinh; @@ -8348,6 +8349,8 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { return parseFunctionArgs2((f1, f2) -> arrayGet(f1, f2)); else if (parseFunctionNameIf("ARRAY_CAT", "ARRAY_CONCAT")) return parseFunctionArgs2((f1, f2) -> arrayConcat(f1, f2)); + else if (parseFunctionNameIf("ARRAY_REMOVE")) + return parseFunctionArgs2((f1, f2) -> arrayRemove((Field) f1, (Field) f2)); break; diff --git a/jOOQ/src/main/java/org/jooq/impl/QOM.java b/jOOQ/src/main/java/org/jooq/impl/QOM.java index 57143b4d0e..0a0cc5c7c9 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -4855,6 +4855,19 @@ public final class QOM { // ArrayOverlap {} + /** + * The ARRAY REMOVE function. + *

+ * Remove an element from an array. + */ + public /*sealed*/ interface ArrayRemove + extends + UOperator2, Field, Field>, + org.jooq.Field + //permits + // ArrayRemove + {} + /** * The NVL function. *

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 e42abba4dc..5a2c3d3325 100644 --- a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java +++ b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java @@ -355,10 +355,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_remove(anyarray, anyelement) function. *

- * Example:


+     * Example:
+     *
+     * 
+     * 
      * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
-     * 
+ *
+ *
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayConcat(Object[], Object)} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayRemove(T[] array, T element) { @@ -368,10 +376,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_remove(anyarray, anyelement) function. *

- * Example:


+     * Example:
+     *
+     * 
+     * 
      * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
-     * 
+ *
+ *
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayConcat(Field, Object)} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayRemove(Field array, T element) { @@ -381,10 +397,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_remove(anyarray, anyelement) function. *

- * Example:


+     * Example:
+     *
+     * 
+     * 
      * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
-     * 
+ *
+ *
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayConcat(Object[], Field)} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayRemove(T[] array, Field element) { @@ -394,10 +418,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_remove(anyarray, anyelement) function. *

- * Example:


+     * Example:
+     *
+     * 
+     * 
      * {1,3} = array_remove(ARRAY[1,2,3,2], 2)
-     * 
+ *
+ *
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayConcat(Field, Field)} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayRemove(Field array, Field element) {