diff --git a/exposed-core/api/exposed-core.api b/exposed-core/api/exposed-core.api index ac30e9c32d..97d24a4ffc 100644 --- a/exposed-core/api/exposed-core.api +++ b/exposed-core/api/exposed-core.api @@ -1208,6 +1208,9 @@ public final class org/jetbrains/exposed/sql/IntegerColumnType : org/jetbrains/e public synthetic fun valueFromDB (Ljava/lang/Object;)Ljava/lang/Object; } +public abstract interface annotation class org/jetbrains/exposed/sql/InternalApi : java/lang/annotation/Annotation { +} + public final class org/jetbrains/exposed/sql/Intersect : org/jetbrains/exposed/sql/SetOperation { public fun (Lorg/jetbrains/exposed/sql/AbstractQuery;Lorg/jetbrains/exposed/sql/AbstractQuery;)V public fun copy ()Lorg/jetbrains/exposed/sql/Intersect; diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Annotations.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Annotations.kt new file mode 100644 index 0000000000..e724d25b40 --- /dev/null +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Annotations.kt @@ -0,0 +1,44 @@ +package org.jetbrains.exposed.sql + +/** + * API marked with this annotation is experimental. + * Any behavior associated with its use is not guaranteed to be stable. + */ +@RequiresOptIn( + message = "This database migration API is experimental. " + + "Its usage must be marked with '@OptIn(org.jetbrains.exposed.sql.ExperimentalDatabaseMigrationApi::class)' " + + "or '@org.jetbrains.exposed.sql.ExperimentalDatabaseMigrationApi'." +) +@Target(AnnotationTarget.FUNCTION) +annotation class ExperimentalDatabaseMigrationApi + +/** + * API marked with this annotation is experimental. + * Any behavior associated with its use is not guaranteed to be stable. + */ +@RequiresOptIn( + message = "This API is experimental and the behavior defined by setting this value to 'true' is now the default. " + + "Its usage must be marked with '@OptIn(org.jetbrains.exposed.sql.ExperimentalKeywordApi::class)' " + + "or '@org.jetbrains.exposed.sql.ExperimentalKeywordApi'." +) +@Target(AnnotationTarget.PROPERTY) +annotation class ExperimentalKeywordApi + +/** + * API marked with this annotation is internal and should not be used outside Exposed. + * It may be changed or removed in the future without notice. + * Using it outside Exposed may result in undefined and unexpected behaviour. + */ +@RequiresOptIn( + level = RequiresOptIn.Level.ERROR, + message = "This API is internal in Exposed and should not be used. It may be changed or removed in the future without notice." +) +@Target( + AnnotationTarget.CLASS, + AnnotationTarget.CONSTRUCTOR, + AnnotationTarget.FUNCTION, + AnnotationTarget.PROPERTY, + AnnotationTarget.PROPERTY_SETTER, + AnnotationTarget.TYPEALIAS +) +annotation class InternalApi diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ColumnType.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ColumnType.kt index dbb3d5bd18..026718272c 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ColumnType.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/ColumnType.kt @@ -1114,6 +1114,7 @@ interface JsonColumnMarker { * * @throws IllegalStateException If no column type mapping is found and a [defaultType] is not provided. */ +@InternalApi fun resolveColumnType( klass: KClass, defaultType: ColumnType? = null diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt index fde9b909b7..b946b096d3 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/DatabaseConfig.kt @@ -141,11 +141,3 @@ class DatabaseConfig private constructor( } } } - -@RequiresOptIn( - message = "This API is experimental and the behavior defined by setting this value to 'true' is now the default. " + - "Its usage must be marked with '@OptIn(org.jetbrains.exposed.sql.ExperimentalKeywordApi::class)' " + - "or '@org.jetbrains.exposed.sql.ExperimentalKeywordApi'." -) -@Target(AnnotationTarget.PROPERTY) -annotation class ExperimentalKeywordApi diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Op.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Op.kt index c915276699..cca68f99db 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Op.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Op.kt @@ -692,8 +692,10 @@ fun decimalLiteral(value: BigDecimal): LiteralOp = LiteralOp(Decimal * * @throws IllegalStateException If no column type mapping is found and a [delegateType] is not provided. */ -inline fun arrayLiteral(value: List, delegateType: ColumnType? = null): LiteralOp> = - LiteralOp(ArrayColumnType(delegateType ?: resolveColumnType(T::class)), value) +inline fun arrayLiteral(value: List, delegateType: ColumnType? = null): LiteralOp> { + @OptIn(InternalApi::class) + return LiteralOp(ArrayColumnType(delegateType ?: resolveColumnType(T::class)), value) +} // Query Parameters @@ -769,8 +771,10 @@ fun blobParam(value: ExposedBlob, useObjectIdentifier: Boolean = false): Express * * @throws IllegalStateException If no column type mapping is found and a [delegateType] is not provided. */ -inline fun arrayParam(value: List, delegateType: ColumnType? = null): Expression> = - QueryParameter(value, ArrayColumnType(delegateType ?: resolveColumnType(T::class))) +inline fun arrayParam(value: List, delegateType: ColumnType? = null): Expression> { + @OptIn(InternalApi::class) + return QueryParameter(value, ArrayColumnType(delegateType ?: resolveColumnType(T::class))) +} // Misc. 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 bb2b293876..be9e9495b4 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 @@ -126,6 +126,7 @@ fun anyFrom(subQuery: AbstractQuery<*>): Op = AllAnyFromSubQueryOp(true, */ inline fun anyFrom(array: Array, delegateType: ColumnType? = null): Op { // 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, columnType) } @@ -149,6 +150,7 @@ fun allFrom(subQuery: AbstractQuery<*>): Op = AllAnyFromSubQueryOp(false, */ inline fun allFrom(array: Array, delegateType: ColumnType? = null): Op { // 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, columnType) } diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt index cceaaf7b32..befcbc8bbc 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SchemaUtils.kt @@ -888,11 +888,3 @@ object SchemaUtils { } } } - -@RequiresOptIn( - message = "This database migration API is experimental. " + - "Its usage must be marked with '@OptIn(org.jetbrains.exposed.sql.ExperimentalDatabaseMigrationApi::class)' " + - "or '@org.jetbrains.exposed.sql.ExperimentalDatabaseMigrationApi'." -) -@Target(AnnotationTarget.FUNCTION) -annotation class ExperimentalDatabaseMigrationApi diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt index 98afc82da5..5d531443dd 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt @@ -844,8 +844,10 @@ open class Table(name: String = "") : ColumnSet(), DdlAware { * when using the PostgreSQL dialect is allowed, but this value will be ignored by the database. * @throws IllegalStateException If no column type mapping is found. */ - inline fun array(name: String, maximumCardinality: Int? = null): Column> = - array(name, resolveColumnType(T::class), maximumCardinality) + inline fun array(name: String, maximumCardinality: Int? = null): Column> { + @OptIn(InternalApi::class) + return array(name, resolveColumnType(T::class), maximumCardinality) + } // Auto-generated values diff --git a/exposed-json/src/main/kotlin/org/jetbrains/exposed/sql/json/JsonFunctions.kt b/exposed-json/src/main/kotlin/org/jetbrains/exposed/sql/json/JsonFunctions.kt index 8055b28622..143ea819ed 100644 --- a/exposed-json/src/main/kotlin/org/jetbrains/exposed/sql/json/JsonFunctions.kt +++ b/exposed-json/src/main/kotlin/org/jetbrains/exposed/sql/json/JsonFunctions.kt @@ -44,6 +44,7 @@ inline fun ExpressionWithColumnType<*>.extract( vararg path: String, toScalar: Boolean = true ): Extract { + @OptIn(InternalApi::class) val columnType = resolveColumnType( T::class, defaultType = JsonColumnType(