[jOOQ/jOOQ#11981] Pull up PostgresDSL::arrayRemove
This commit is contained in:
parent
9d75ad1b2e
commit
a1a67a0b17
172
jOOQ/src/main/java/org/jooq/impl/ArrayRemove.java
Normal file
172
jOOQ/src/main/java/org/jooq/impl/ArrayRemove.java
Normal file
@ -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 <code>ARRAY REMOVE</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class ArrayRemove<T>
|
||||
extends
|
||||
AbstractField<T[]>
|
||||
implements
|
||||
QOM.ArrayRemove<T>
|
||||
{
|
||||
|
||||
final Field<T[]> arg1;
|
||||
final Field<T> arg2;
|
||||
|
||||
ArrayRemove(
|
||||
Field<T[]> arg1,
|
||||
Field<T> 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<T[]> $arg1() {
|
||||
return arg1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Field<T> $arg2() {
|
||||
return arg2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.ArrayRemove<T> $arg1(Field<T[]> newValue) {
|
||||
return $constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.ArrayRemove<T> $arg2(Field<T> newValue) {
|
||||
return $constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T[]>, ? super Field<T>, ? extends QOM.ArrayRemove<T>> $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);
|
||||
}
|
||||
}
|
||||
@ -19780,6 +19780,54 @@ public class DSL {
|
||||
return new ArrayOverlap<>(arg1, arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_REMOVE</code> function.
|
||||
* <p>
|
||||
* Remove an element from an array.
|
||||
*
|
||||
* @param arg2 is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(T[] arg1, T arg2) {
|
||||
return new ArrayRemove<>(Tools.field(arg1), Tools.field(arg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_REMOVE</code> function.
|
||||
* <p>
|
||||
* Remove an element from an array.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(T[] arg1, Field<T> arg2) {
|
||||
return new ArrayRemove<>(Tools.field(arg1), arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_REMOVE</code> function.
|
||||
* <p>
|
||||
* Remove an element from an array.
|
||||
*
|
||||
* @param arg2 is wrapped as {@link #val(Object)}.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(Field<T[]> arg1, T arg2) {
|
||||
return new ArrayRemove<>(arg1, Tools.field(arg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_REMOVE</code> function.
|
||||
* <p>
|
||||
* Remove an element from an array.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(Field<T[]> arg1, Field<T> arg2) {
|
||||
return new ArrayRemove<>(arg1, arg2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Utility functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -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");
|
||||
|
||||
@ -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<Void[]>) f1, (Field<Void>) f2));
|
||||
|
||||
break;
|
||||
|
||||
|
||||
@ -4855,6 +4855,19 @@ public final class QOM {
|
||||
// ArrayOverlap
|
||||
{}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY REMOVE</code> function.
|
||||
* <p>
|
||||
* Remove an element from an array.
|
||||
*/
|
||||
public /*sealed*/ interface ArrayRemove<T>
|
||||
extends
|
||||
UOperator2<Field<T[]>, Field<T>, Field<T[]>>,
|
||||
org.jooq.Field<T[]>
|
||||
//permits
|
||||
// ArrayRemove
|
||||
{}
|
||||
|
||||
/**
|
||||
* The <code>NVL</code> function.
|
||||
* <p>
|
||||
|
||||
@ -355,10 +355,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_remove(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1,3} = array_remove(ARRAY[1,2,3,2], 2)
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Object[], Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(T[] array, T element) {
|
||||
@ -368,10 +376,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_remove(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1,3} = array_remove(ARRAY[1,2,3,2], 2)
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Field, Object)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(Field<T[]> array, T element) {
|
||||
@ -381,10 +397,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_remove(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1,3} = array_remove(ARRAY[1,2,3,2], 2)
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Object[], Field)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(T[] array, Field<T> element) {
|
||||
@ -394,10 +418,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_remove(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1,3} = array_remove(ARRAY[1,2,3,2], 2)
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Field, Field)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Field<T[]> arrayRemove(Field<T[]> array, Field<T> element) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user