diff --git a/jOOQ/src/main/java/org/jooq/impl/ArrayAppend.java b/jOOQ/src/main/java/org/jooq/impl/ArrayAppend.java new file mode 100644 index 0000000000..3ba35c064c --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayAppend.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 APPEND statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class ArrayAppend +extends + AbstractField +implements + QOM.ArrayAppend +{ + + final Field arg1; + final Field arg2; + + ArrayAppend( + Field arg1, + Field arg2 + ) { + super( + N_ARRAY_APPEND, + 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_APPEND, 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.ArrayAppend $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.ArrayAppend $arg2(Field newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.ArrayAppend> $constructor() { + return (a1, a2) -> new ArrayAppend<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.ArrayAppend 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/ArrayPrepend.java b/jOOQ/src/main/java/org/jooq/impl/ArrayPrepend.java new file mode 100644 index 0000000000..9660e68538 --- /dev/null +++ b/jOOQ/src/main/java/org/jooq/impl/ArrayPrepend.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 PREPEND statement. + */ +@SuppressWarnings({ "rawtypes", "unchecked", "unused" }) +final class ArrayPrepend +extends + AbstractField +implements + QOM.ArrayPrepend +{ + + final Field arg1; + final Field arg2; + + ArrayPrepend( + Field arg1, + Field arg2 + ) { + super( + N_ARRAY_PREPEND, + allNotNull(((DataType) OTHER).getArrayDataType(), arg1, arg2) + ); + + this.arg1 = nullSafeNotNull(arg1, (DataType) OTHER); + this.arg2 = nullSafeNotNull(arg2, ((DataType) OTHER).getArrayDataType()); + } + + // ------------------------------------------------------------------------- + // 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_PREPEND, 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.ArrayPrepend $arg1(Field newValue) { + return $constructor().apply(newValue, $arg2()); + } + + @Override + public final QOM.ArrayPrepend $arg2(Field newValue) { + return $constructor().apply($arg1(), newValue); + } + + @Override + public final Function2, ? super Field, ? extends QOM.ArrayPrepend> $constructor() { + return (a1, a2) -> new ArrayPrepend<>(a1, a2); + } + + // ------------------------------------------------------------------------- + // XXX: The Object API + // ------------------------------------------------------------------------- + + @Override + public boolean equals(Object that) { + if (that instanceof QOM.ArrayPrepend 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 e0a709c133..392085c2eb 100644 --- a/jOOQ/src/main/java/org/jooq/impl/DSL.java +++ b/jOOQ/src/main/java/org/jooq/impl/DSL.java @@ -19736,6 +19736,102 @@ public class DSL { return new ArrayConcat<>(arg1, arg2); } + /** + * The ARRAY_APPEND function. + *

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

+ * Append an element to an array. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayAppend(T[] arg1, Field arg2) { + return new ArrayAppend<>(Tools.field(arg1), arg2); + } + + /** + * The ARRAY_APPEND function. + *

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

+ * Append an element to an array. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayAppend(Field arg1, Field arg2) { + return new ArrayAppend<>(arg1, arg2); + } + + /** + * The ARRAY_PREPEND function. + *

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

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

+ * Prepend an element to an array. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayPrepend(Field arg1, T[] arg2) { + return new ArrayPrepend<>(arg1, Tools.field(arg2)); + } + + /** + * The ARRAY_PREPEND function. + *

+ * Prepend an element to an array. + */ + @NotNull + @Support({ POSTGRES, YUGABYTEDB }) + public static Field arrayPrepend(Field arg1, Field arg2) { + return new ArrayPrepend<>(arg1, arg2); + } + /** * The ARRAY_OVERLAP function. *

diff --git a/jOOQ/src/main/java/org/jooq/impl/Names.java b/jOOQ/src/main/java/org/jooq/impl/Names.java index 5b0506d6ac..6f7e17e586 100644 --- a/jOOQ/src/main/java/org/jooq/impl/Names.java +++ b/jOOQ/src/main/java/org/jooq/impl/Names.java @@ -345,9 +345,11 @@ final class Names { static final Name N_ACOSH = systemName("acosh"); static final Name N_ACOTH = systemName("acoth"); static final Name N_ANY_VALUE = systemName("any_value"); + static final Name N_ARRAY_APPEND = systemName("array_append"); 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_PREPEND = systemName("array_prepend"); static final Name N_ARRAY_REMOVE = systemName("array_remove"); static final Name N_ASCII = systemName("ascii"); static final Name N_ASIN = systemName("asin"); diff --git a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java index a585364d57..4af93ee4c5 100644 --- a/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java +++ b/jOOQ/src/main/java/org/jooq/impl/ParserImpl.java @@ -79,8 +79,10 @@ import static org.jooq.impl.DSL.any; import static org.jooq.impl.DSL.anyValue; import static org.jooq.impl.DSL.arrayAgg; import static org.jooq.impl.DSL.arrayAggDistinct; +import static org.jooq.impl.DSL.arrayAppend; import static org.jooq.impl.DSL.arrayConcat; import static org.jooq.impl.DSL.arrayGet; +import static org.jooq.impl.DSL.arrayPrepend; import static org.jooq.impl.DSL.arrayRemove; import static org.jooq.impl.DSL.ascii; import static org.jooq.impl.DSL.asin; @@ -8351,6 +8353,10 @@ final class DefaultParseContext extends AbstractScope implements ParseContext { return parseFunctionArgs2((f1, f2) -> arrayConcat(f1, f2)); else if (parseFunctionNameIf("ARRAY_REMOVE")) return parseFunctionArgs2((f1, f2) -> arrayRemove((Field) f1, (Field) f2)); + else if (parseFunctionNameIf("ARRAY_APPEND")) + return parseFunctionArgs2((f1, f2) -> arrayAppend((Field) f1, (Field) f2)); + else if (parseFunctionNameIf("ARRAY_PREPEND")) + return parseFunctionArgs2((f1, f2) -> arrayPrepend((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 0a0cc5c7c9..e2144840f4 100644 --- a/jOOQ/src/main/java/org/jooq/impl/QOM.java +++ b/jOOQ/src/main/java/org/jooq/impl/QOM.java @@ -4841,6 +4841,32 @@ public final class QOM { // ArrayConcat {} + /** + * The ARRAY APPEND function. + *

+ * Append an element to an array. + */ + public /*sealed*/ interface ArrayAppend + extends + UOperator2, Field, Field>, + org.jooq.Field + //permits + // ArrayAppend + {} + + /** + * The ARRAY PREPEND function. + *

+ * Prepend an element to an array. + */ + public /*sealed*/ interface ArrayPrepend + extends + UOperator2, Field, Field>, + org.jooq.Field + //permits + // ArrayPrepend + {} + /** * The ARRAY OVERLAP 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 5a2c3d3325..93f50ae26b 100644 --- a/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java +++ b/jOOQ/src/main/java/org/jooq/util/postgres/PostgresDSL.java @@ -155,10 +155,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_append(anyarray, anyelement) function. *

- * Example:


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

- * Example:


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

- * Example:


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

- * Example:


+     * Example:
+     *
+     * 
+     * 
      * {1, 2, 3} = array_append(ARRAY[1, 2], 3)
-     * 
+ *
+ *
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayPrepend(Field, Field)} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayAppend(Field array, Field value) { @@ -213,10 +245,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_prepend(anyarray, anyelement) function. *

- * Example:


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

- * Example:


+     * Example:
+     *
+     * 
+     * 
      * {1, 2, 3} = array_prepend(1, ARRAY[2, 3])
-     * 
+ *
+ *
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayPrepend(Field, Object[])} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayPrepend(Field value, T[] array) { @@ -242,7 +290,11 @@ public class PostgresDSL extends DSL { * Example:

      * {1, 2, 3} = array_prepend(1, ARRAY[2, 3])
      * 
+ * + * @deprecated - 3.16.0 - [#14388] - Use + * {@link DSL#arrayPrepend(Object, Field)} instead. */ + @Deprecated @NotNull @Support({ POSTGRES, YUGABYTEDB }) public static Field arrayPrepend(T value, Field array) { @@ -252,10 +304,18 @@ public class PostgresDSL extends DSL { /** * The PostgreSQL array_prepend(anyarray, anyelement) function. *

- * Example:


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