diff --git a/exposed-core/api/exposed-core.api b/exposed-core/api/exposed-core.api index 20adcaeae1..6647990370 100644 --- a/exposed-core/api/exposed-core.api +++ b/exposed-core/api/exposed-core.api @@ -2696,9 +2696,9 @@ public final class org/jetbrains/exposed/sql/functions/math/TanFunction : org/je } public final class org/jetbrains/exposed/sql/ops/AllAnyFromArrayOp : org/jetbrains/exposed/sql/ops/AllAnyFromBaseOp { - public fun (Z[Ljava/lang/Object;Lorg/jetbrains/exposed/sql/ColumnType;)V + public fun (ZLjava/util/List;Lorg/jetbrains/exposed/sql/ColumnType;)V public synthetic fun registerSubSearchArgument (Lorg/jetbrains/exposed/sql/QueryBuilder;Ljava/lang/Object;)V - public fun registerSubSearchArgument (Lorg/jetbrains/exposed/sql/QueryBuilder;[Ljava/lang/Object;)V + public fun registerSubSearchArgument (Lorg/jetbrains/exposed/sql/QueryBuilder;Ljava/util/List;)V } public abstract class org/jetbrains/exposed/sql/ops/AllAnyFromBaseOp : org/jetbrains/exposed/sql/Op { diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt index be9e9495b4..8b5312a626 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt @@ -128,6 +128,21 @@ inline fun anyFrom(array: Array, delegateType: ColumnType? // emptyArray() without type info generates ARRAY[] @OptIn(InternalApi::class) val columnType = delegateType ?: resolveColumnType(T::class, if (array.isEmpty()) TextColumnType() else null) + return AllAnyFromArrayOp(true, array.toList(), columnType) +} + +/** + * Returns this list of data wrapped in the `ANY` operator. This function is only supported by PostgreSQL and H2 dialects. + * + * **Note** If [delegateType] is left `null`, the base column type associated with storing elements of type [T] will be + * resolved according to the internal mapping of the element's type in [resolveColumnType]. + * + * @throws IllegalStateException If no column type mapping is found and a [delegateType] is not provided. + */ +inline fun anyFrom(array: List, delegateType: ColumnType? = null): Op { + // emptyList() without type info generates ARRAY[] + @OptIn(InternalApi::class) + val columnType = delegateType ?: resolveColumnType(T::class, if (array.isEmpty()) TextColumnType() else null) return AllAnyFromArrayOp(true, array, columnType) } @@ -152,6 +167,21 @@ inline fun allFrom(array: Array, delegateType: ColumnType? // emptyArray() without type info generates ARRAY[] @OptIn(InternalApi::class) val columnType = delegateType ?: resolveColumnType(T::class, if (array.isEmpty()) TextColumnType() else null) + return AllAnyFromArrayOp(false, array.toList(), columnType) +} + +/** + * Returns this list of data wrapped in the `ALL` operator. This function is only supported by PostgreSQL and H2 dialects. + * + * **Note** If [delegateType] is left `null`, the base column type associated with storing elements of type [T] will be + * resolved according to the internal mapping of the element's type in [resolveColumnType]. + * + * @throws IllegalStateException If no column type mapping is found and a [delegateType] is not provided. + */ +inline fun allFrom(array: List, delegateType: ColumnType? = null): Op { + // emptyList() without type info generates ARRAY[] + @OptIn(InternalApi::class) + val columnType = delegateType ?: resolveColumnType(T::class, if (array.isEmpty()) TextColumnType() else null) return AllAnyFromArrayOp(false, array, columnType) } @@ -177,7 +207,7 @@ infix operator fun ?> ExpressionWithColumnType.get(index: Int) * @sample org.jetbrains.exposed.sql.tests.shared.types.ArrayColumnTypeTests.testSelectUsingArraySlice */ fun ?> ExpressionWithColumnType.slice(lower: Int? = null, upper: Int? = null): ArraySlice = - ArraySlice(this, lower, upper, ArrayColumnType((this.columnType as ArrayColumnType).delegate)) + ArraySlice(this, lower, upper, this.columnType as ArrayColumnType) // Sequence Manipulation Functions diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ops/AllAnyOps.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ops/AllAnyOps.kt index 3ddb2a7ebb..f04fbc7c11 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ops/AllAnyOps.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ops/AllAnyOps.kt @@ -44,10 +44,10 @@ class AllAnyFromSubQueryOp( */ class AllAnyFromArrayOp( isAny: Boolean, - array: Array, + array: List, private val delegateType: ColumnType -) : AllAnyFromBaseOp>(isAny, array) { - override fun QueryBuilder.registerSubSearchArgument(subSearch: Array) { +) : AllAnyFromBaseOp>(isAny, array) { + override fun QueryBuilder.registerSubSearchArgument(subSearch: List) { registerArgument(ArrayColumnType(delegateType), subSearch) } }