[jOOQ/jOOQ#11981] [jOOQ/jOOQ#14352] Pull up PostgresDSL::arrayOverlap
This implicitly fixes: - [jOOQ/jOOQ#14352] PostgresDSL arrayOverlap does not properly cast arguments
This commit is contained in:
parent
26ec94ce70
commit
9d75ad1b2e
163
jOOQ/src/main/java/org/jooq/impl/ArrayOverlap.java
Normal file
163
jOOQ/src/main/java/org/jooq/impl/ArrayOverlap.java
Normal file
@ -0,0 +1,163 @@
|
||||
/*
|
||||
* 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 OVERLAP</code> statement.
|
||||
*/
|
||||
@SuppressWarnings({ "rawtypes", "unchecked", "unused" })
|
||||
final class ArrayOverlap<T>
|
||||
extends
|
||||
AbstractCondition
|
||||
implements
|
||||
QOM.ArrayOverlap<T>
|
||||
{
|
||||
|
||||
final Field<T[]> arg1;
|
||||
final Field<T[]> arg2;
|
||||
|
||||
ArrayOverlap(
|
||||
Field<T[]> arg1,
|
||||
Field<T[]> arg2
|
||||
) {
|
||||
|
||||
this.arg1 = nullSafeNotNull(arg1, ((DataType) OTHER).getArrayDataType());
|
||||
this.arg2 = nullSafeNotNull(arg2, ((DataType) OTHER).getArrayDataType());
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: QueryPart API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public final void accept(Context<?> ctx) {
|
||||
switch (ctx.family()) {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
default:
|
||||
ctx.sql('(').visit(arg1).sql(" && ").visit(arg2).sql(')');
|
||||
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.ArrayOverlap<T> $arg1(Field<T[]> newValue) {
|
||||
return $constructor().apply(newValue, $arg2());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final QOM.ArrayOverlap<T> $arg2(Field<T[]> newValue) {
|
||||
return $constructor().apply($arg1(), newValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final Function2<? super Field<T[]>, ? super Field<T[]>, ? extends QOM.ArrayOverlap<T>> $constructor() {
|
||||
return (a1, a2) -> new ArrayOverlap<>(a1, a2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// XXX: The Object API
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@Override
|
||||
public boolean equals(Object that) {
|
||||
if (that instanceof QOM.ArrayOverlap<?> o) {
|
||||
return
|
||||
StringUtils.equals($arg1(), o.$arg1()) &&
|
||||
StringUtils.equals($arg2(), o.$arg2())
|
||||
;
|
||||
}
|
||||
else
|
||||
return super.equals(that);
|
||||
}
|
||||
}
|
||||
@ -19736,6 +19736,50 @@ public class DSL {
|
||||
return new ArrayConcat<>(arg1, arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_OVERLAP</code> function.
|
||||
* <p>
|
||||
* Check if 2 arrays overlap.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(T[] arg1, T[] arg2) {
|
||||
return new ArrayOverlap<>(Tools.field(arg1), Tools.field(arg2));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_OVERLAP</code> function.
|
||||
* <p>
|
||||
* Check if 2 arrays overlap.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(T[] arg1, Field<T[]> arg2) {
|
||||
return new ArrayOverlap<>(Tools.field(arg1), arg2);
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_OVERLAP</code> function.
|
||||
* <p>
|
||||
* Check if 2 arrays overlap.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(Field<T[]> arg1, T[] arg2) {
|
||||
return new ArrayOverlap<>(arg1, Tools.field(arg2, arg1));
|
||||
}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY_OVERLAP</code> function.
|
||||
* <p>
|
||||
* Check if 2 arrays overlap.
|
||||
*/
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(Field<T[]> arg1, Field<T[]> arg2) {
|
||||
return new ArrayOverlap<>(arg1, arg2);
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Utility functions
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
@ -347,6 +347,7 @@ final class Names {
|
||||
static final Name N_ANY_VALUE = systemName("any_value");
|
||||
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_ASCII = systemName("ascii");
|
||||
static final Name N_ASIN = systemName("asin");
|
||||
static final Name N_ASINH = systemName("asinh");
|
||||
|
||||
@ -4841,6 +4841,20 @@ public final class QOM {
|
||||
// ArrayConcat
|
||||
{}
|
||||
|
||||
/**
|
||||
* The <code>ARRAY OVERLAP</code> function.
|
||||
* <p>
|
||||
* Check if 2 arrays overlap.
|
||||
*/
|
||||
public /*sealed*/ interface ArrayOverlap<T>
|
||||
extends
|
||||
UReturnsNullOnNullInput,
|
||||
UOperator2<Field<T[]>, Field<T[]>, Condition>,
|
||||
org.jooq.Condition
|
||||
//permits
|
||||
// ArrayOverlap
|
||||
{}
|
||||
|
||||
/**
|
||||
* The <code>NVL</code> function.
|
||||
* <p>
|
||||
|
||||
@ -71,10 +71,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array1 && array2</code> overlap operator.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* true = array[1, 2, 3] && array[3, 4, 5]
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14352] - Use
|
||||
* {@link DSL#arrayOverlap(Object[], Object[])} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(T[] left, T[] right) {
|
||||
@ -84,10 +92,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array1 && array2</code> overlap operator.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* true = array[1, 2, 3] && array[3, 4, 5]
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14352] - Use
|
||||
* {@link DSL#arrayOverlap(Object[], Field)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(T[] left, Field<T[]> right) {
|
||||
@ -97,10 +113,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array1 && array2</code> overlap operator.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* true = array[1, 2, 3] && array[3, 4, 5]
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14352] - Use
|
||||
* {@link DSL#arrayOverlap(Field, Object[])} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(Field<T[]> left, T[] right) {
|
||||
@ -110,10 +134,18 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array1 && array2</code> overlap operator.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* true = array[1, 2, 3] && array[3, 4, 5]
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14352] - Use
|
||||
* {@link DSL#arrayOverlap(Field, Field)} instead.
|
||||
*/
|
||||
@Deprecated
|
||||
@NotNull
|
||||
@Support({ POSTGRES, YUGABYTEDB })
|
||||
public static <T> Condition arrayOverlap(Field<T[]> left, Field<T[]> right) {
|
||||
@ -260,9 +292,13 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_cat(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1, 2, 3, 4, 5} = array_cat(ARRAY[1, 2], ARRAY[3, 4, 5])
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Object[], Field)} instead.
|
||||
@ -277,9 +313,13 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_cat(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1, 2, 3, 4, 5} = array_cat(ARRAY[1, 2], ARRAY[3, 4, 5])
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Field, Object[])} instead.
|
||||
@ -294,9 +334,13 @@ public class PostgresDSL extends DSL {
|
||||
/**
|
||||
* The PostgreSQL <code>array_cat(anyarray, anyelement)</code> function.
|
||||
* <p>
|
||||
* Example: <pre><code>
|
||||
* Example:
|
||||
*
|
||||
* <pre>
|
||||
* <code>
|
||||
* {1, 2, 3, 4, 5} = array_cat(ARRAY[1, 2], ARRAY[3, 4, 5])
|
||||
* </code></pre>
|
||||
* </code>
|
||||
* </pre>
|
||||
*
|
||||
* @deprecated - 3.16.0 - [#14388] - Use
|
||||
* {@link DSL#arrayConcat(Field, Field)} instead.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user