Skip to content

Commit

Permalink
deprecate: Raise deprecation levels of API elements
Browse files Browse the repository at this point in the history
Raise deprecation levels of all elements that have been deprecated for more
than 3 releases.
  • Loading branch information
bog-walk committed Jan 30, 2025
1 parent e622c7c commit 8883a64
Show file tree
Hide file tree
Showing 17 changed files with 105 additions and 108 deletions.
88 changes: 42 additions & 46 deletions exposed-core/api/exposed-core.api

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ abstract class AbstractQuery<T : AbstractQuery<T>>(
@Deprecated(
"This function will be removed in future releases.",
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
override fun limit(n: Int, offset: Long): T = apply {
limit = n
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Database private constructor(
) {
/** Whether nested transaction blocks are configured to act like top-level transactions. */
var useNestedTransactions: Boolean = config.useNestedTransactions
@Deprecated("Use DatabaseConfig to define the useNestedTransactions", level = DeprecationLevel.ERROR)
@Deprecated("Use DatabaseConfig to define the useNestedTransactions", level = DeprecationLevel.HIDDEN)
@TestOnly
set

Expand Down Expand Up @@ -94,7 +94,7 @@ class Database private constructor(
var defaultFetchSize: Int? = config.defaultFetchSize
private set

@Deprecated("Use DatabaseConfig to define the defaultFetchSize", level = DeprecationLevel.ERROR)
@Deprecated("Use DatabaseConfig to define the defaultFetchSize", level = DeprecationLevel.HIDDEN)
@TestOnly
fun defaultFetchSize(size: Int): Database {
defaultFetchSize = size
Expand Down Expand Up @@ -236,7 +236,7 @@ class Database private constructor(
*/
@Deprecated(
message = "Use Database.connect() with a connection pool DataSource instead. This may be removed in future releases.",
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun connectPool(
datasource: ConnectionPoolDataSource,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@ class DatabaseConfig private constructor(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxAttempts"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
val defaultRepetitionAttempts: Int,
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMinRetryDelay"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
val defaultMinRepetitionDelay: Long,
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxRetryDelay"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
val defaultMaxRepetitionDelay: Long,
val defaultReadOnly: Boolean,
Expand Down Expand Up @@ -140,7 +140,7 @@ class DatabaseConfig private constructor(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxAttempts"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
var defaultRepetitionAttempts: Int
get() = defaultMaxAttempts
Expand All @@ -149,7 +149,7 @@ class DatabaseConfig private constructor(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMinRetryDelay"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
var defaultMinRepetitionDelay: Long
get() = defaultMinRetryDelay
Expand All @@ -158,7 +158,7 @@ class DatabaseConfig private constructor(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxRetryDelay"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
var defaultMaxRepetitionDelay: Long
get() = defaultMaxRetryDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,18 @@ import org.jetbrains.exposed.sql.vendors.ForUpdateOption
/** Represents the iterable elements of a database result. */
interface SizedIterable<out T> : Iterable<T> {
@Deprecated(
"This function will be removed in future releases.",
"This function will be removed in future releases. Overrides for replacement methods limit(count) " +
"& offset(start) must be provided when implementing this interface.",
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
fun limit(n: Int, offset: Long): SizedIterable<T>

/** Returns a new [SizedIterable] containing only [count] elements. */
fun limit(count: Int): SizedIterable<T> = limit(count, 0)
fun limit(count: Int): SizedIterable<T>

/** Returns a new [SizedIterable] containing only elements starting from the specified [start]. */
fun offset(start: Long): SizedIterable<T> = limit(Int.MAX_VALUE, start)
fun offset(start: Long): SizedIterable<T>

/** Returns the number of elements stored. */
fun count(): Long
Expand Down Expand Up @@ -53,7 +54,7 @@ class EmptySizedIterable<out T> : SizedIterable<T>, Iterator<T> {
@Deprecated(
"This function will be removed in future releases.",
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
override fun limit(n: Int, offset: Long): SizedIterable<T> = this

Expand Down Expand Up @@ -83,7 +84,7 @@ class SizedCollection<out T>(val delegate: Collection<T>) : SizedIterable<T> {
@Deprecated(
"This function will be removed in future releases.",
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
override fun limit(n: Int, offset: Long): SizedIterable<T> {
return if (offset >= Int.MAX_VALUE) {
Expand Down Expand Up @@ -126,7 +127,7 @@ class LazySizedCollection<out T>(_delegate: SizedIterable<T>) : SizedIterable<T>
@Deprecated(
"This function will be removed in future releases.",
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
override fun limit(n: Int, offset: Long): SizedIterable<T> = LazySizedCollection(delegate.limit(n).offset(offset))
override fun limit(count: Int): SizedIterable<T> = LazySizedCollection(delegate.limit(count))
Expand Down Expand Up @@ -196,7 +197,7 @@ infix fun <T, R> SizedIterable<T>.mapLazy(f: (T) -> R): SizedIterable<R> {
@Deprecated(
"This function will be removed in future releases.",
ReplaceWith("limit(n).offset(offset)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
override fun limit(n: Int, offset: Long): SizedIterable<R> = source.copy().limit(n).offset(offset).mapLazy(f)
override fun limit(count: Int): SizedIterable<R> = source.copy().limit(count).mapLazy(f)
Expand Down
28 changes: 14 additions & 14 deletions exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Queries.kt
Original file line number Diff line number Diff line change
Expand Up @@ -11,30 +11,30 @@ import kotlin.sequences.Sequence
@Deprecated(
message = "As part of SELECT DSL design changes, this will be removed in future releases.",
replaceWith = ReplaceWith("selectAll().where { where.invoke() }", "import org.jetbrains.exposed.sql.selectAll"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
inline fun FieldSet.select(where: SqlExpressionBuilder.() -> Op<Boolean>): Query = Query(this, SqlExpressionBuilder.where())

@Suppress("UnusedParameter")
@Deprecated(
message = "This method only exists as part of the migration for SELECT DSL design changes.",
replaceWith = ReplaceWith("where { where.invoke() }"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
inline fun Query.select(where: SqlExpressionBuilder.() -> Op<Boolean>): Query = this

@Deprecated(
message = "As part of SELECT DSL design changes, this will be removed in future releases.",
replaceWith = ReplaceWith("selectAll().where(where)", "import org.jetbrains.exposed.sql.selectAll"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun FieldSet.select(where: Op<Boolean>): Query = Query(this, where)

@Suppress("UnusedParameter")
@Deprecated(
message = "This method only exists as part of the migration for SELECT DSL design changes.",
replaceWith = ReplaceWith("where(where)"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun Query.select(where: Op<Boolean>): Query = this

Expand All @@ -53,7 +53,7 @@ fun FieldSet.selectAll(): Query = Query(this, null)
"selectAll().where { where.invoke() }.fetchBatchedResults(batchSize)",
"import org.jetbrains.exposed.sql.selectAll"
),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun FieldSet.selectBatched(
batchSize: Int = 1000,
Expand All @@ -65,7 +65,7 @@ fun FieldSet.selectBatched(
@Deprecated(
message = "This method only exists as part of the migration for SELECT DSL design changes.",
replaceWith = ReplaceWith("where { where.invoke() }.fetchBatchedResults(batchSize)"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun Query.selectBatched(
batchSize: Int = 1000,
Expand All @@ -80,7 +80,7 @@ fun Query.selectBatched(
"selectAll().fetchBatchedResults(batchSize)",
"import org.jetbrains.exposed.sql.selectAll"
),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun FieldSet.selectAllBatched(
batchSize: Int = 1000
Expand All @@ -91,7 +91,7 @@ fun FieldSet.selectAllBatched(
@Deprecated(
message = "This method only exists as part of the migration for SELECT DSL design changes.",
replaceWith = ReplaceWith("fetchBatchedResults(batchSize)"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun Query.selectAllBatched(
batchSize: Int = 1000
Expand All @@ -104,7 +104,7 @@ fun Query.selectAllBatched(
"[YouTrack](https://youtrack.jetbrains.com/issue/EXPOSED-550/DeleteStatement-holds-unused-offset-property) " +
"with a use-case if your database supports the OFFSET clause in a DELETE statement.",
ReplaceWith("deleteWhere(limit) { op.invoke() }"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
@Suppress("UnusedParameter")
fun <T : Table> T.deleteWhere(limit: Int? = null, offset: Long? = null, op: T.(ISqlExpressionBuilder) -> Op<Boolean>): Int =
Expand All @@ -129,7 +129,7 @@ inline fun <T : Table> T.deleteWhere(
"[YouTrack](https://youtrack.jetbrains.com/issue/EXPOSED-550/DeleteStatement-holds-unused-offset-property) " +
"with a use-case if your database supports the OFFSET clause in a DELETE statement.",
ReplaceWith("deleteIgnoreWhere(limit) { op.invoke() }"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
@Suppress("UnusedParameter")
fun <T : Table> T.deleteIgnoreWhere(limit: Int? = null, offset: Long? = null, op: T.(ISqlExpressionBuilder) -> Op<Boolean>): Int =
Expand Down Expand Up @@ -742,7 +742,7 @@ fun <T : Table> T.upsert(
@Deprecated(
"This `upsert()` with `onUpdate` parameter that accepts a List will be removed in future releases. " +
"Please use `upsert()` with `onUpdate` parameter that takes an `UpdateStatement` lambda block instead.",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
fun <T : Table> T.upsert(
vararg keys: Column<*>,
Expand Down Expand Up @@ -793,7 +793,7 @@ fun <T : Table> T.upsertReturning(
@Deprecated(
"This `upsertReturning()` with `onUpdate` parameter that accepts a List will be removed in future releases. " +
"Please use `upsertReturning()` with `onUpdate` parameter that takes an `UpdateStatement` lambda block instead.",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
fun <T : Table> T.upsertReturning(
vararg keys: Column<*>,
Expand Down Expand Up @@ -841,7 +841,7 @@ fun <T : Table, E : Any> T.batchUpsert(
@Deprecated(
"This `batchUpsert()` with `onUpdate` parameter that accepts a List will be removed in future releases. " +
"Please use `batchUpsert()` with `onUpdate` parameter that takes an `UpdateStatement` lambda block instead.",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
fun <T : Table, E : Any> T.batchUpsert(
data: Iterable<E>,
Expand Down Expand Up @@ -887,7 +887,7 @@ fun <T : Table, E : Any> T.batchUpsert(
@Deprecated(
"This `batchUpsert()` with `onUpdate` parameter that accepts a List will be removed in future releases. " +
"Please use `batchUpsert()` with `onUpdate` parameter that takes an `UpdateStatement` lambda block instead.",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
fun <T : Table, E : Any> T.batchUpsert(
data: Sequence<E>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ open class Query(override var set: FieldSet, where: Op<Boolean>?) : AbstractQuer
@Deprecated(
message = "As part of SELECT DSL design changes, this will be removed in future releases.",
replaceWith = ReplaceWith("adjustSelect { body.invoke() }"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun adjustSlice(body: ColumnSet.(FieldSet) -> FieldSet): Query = apply { set = set.source.body(set) }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,14 +111,14 @@ abstract class ColumnSet : FieldSet {
@Deprecated(
message = "As part of SELECT DSL design changes, this will be removed in future releases.",
replaceWith = ReplaceWith("select(column, *columns)"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun slice(column: Expression<*>, vararg columns: Expression<*>): FieldSet = Slice(this, listOf(column) + columns)

@Deprecated(
message = "As part of SELECT DSL design changes, this will be removed in future releases.",
replaceWith = ReplaceWith("select(columns)"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
fun slice(columns: List<Expression<*>>): FieldSet = Slice(this, columns)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ open class Transaction(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("maxAttempts"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
var repetitionAttempts: Int
get() = maxAttempts
Expand All @@ -96,7 +96,7 @@ open class Transaction(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("minRetryDelay"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
var minRepetitionDelay: Long
get() = minRetryDelay
Expand All @@ -105,7 +105,7 @@ open class Transaction(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("maxRetryDelay"),
level = DeprecationLevel.ERROR
level = DeprecationLevel.HIDDEN
)
var maxRepetitionDelay: Long
get() = maxRetryDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class BatchUpsertStatement(
) : BaseBatchInsertStatement(table, ignore = false, shouldReturnGeneratedValues), UpsertBuilder {
@Deprecated(
"This constructor with `onUpdate` that takes a List may be removed in future releases.",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
constructor(
table: Table,
Expand All @@ -38,12 +38,11 @@ open class BatchUpsertStatement(
shouldReturnGeneratedValues: Boolean
) : this(table, keys = keys, onUpdateExclude, where, shouldReturnGeneratedValues) {
onUpdate?.let {
this.onUpdate = it
updateValues.putAll(it)
}
}

@Deprecated("This property will be removed in future releases.", level = DeprecationLevel.WARNING)
@Deprecated("This property will be removed in future releases.", level = DeprecationLevel.ERROR)
var onUpdate: List<Pair<Column<*>, Expression<*>>>? = null
private set

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ open class DeleteStatement(
@Deprecated(
"This constructor will be removed in future releases.",
ReplaceWith("DeleteStatement(targetsSet = table, where, isIgnore, limit, emptyList())"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
@Suppress("UnusedPrivateProperty")
constructor(
Expand All @@ -42,15 +42,15 @@ open class DeleteStatement(
"This property will be removed in future releases and replaced with a property that stores a `ColumnSet`," +
"which may be a `Table` or a `Join`. To access the table(s) to which the columns belong, use `ColumnSet.targetTables()`",
ReplaceWith("targetsSet"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
val table: Table = targets.first()

@Deprecated(
"This property is not being used and will be removed in future releases. Please leave a comment on " +
"[YouTrack](https://youtrack.jetbrains.com/issue/EXPOSED-550/DeleteStatement-holds-unused-offset-property) " +
"with a use-case if your database supports the OFFSET clause in a DELETE statement.",
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
val offset: Long? = null

Expand Down Expand Up @@ -92,7 +92,7 @@ open class DeleteStatement(
"[YouTrack](https://youtrack.jetbrains.com/issue/EXPOSED-550/DeleteStatement-holds-unused-offset-property) " +
"with a use-case if your database supports the OFFSET clause in a DELETE statement.",
ReplaceWith("where(transaction, table, op, isIgnore, limit)"),
DeprecationLevel.WARNING
DeprecationLevel.ERROR
)
@Suppress("UnusedParameter")
fun where(transaction: Transaction, table: Table, op: Op<Boolean>, isIgnore: Boolean = false, limit: Int? = null, offset: Long? = null): Int =
Expand Down
Loading

0 comments on commit 8883a64

Please sign in to comment.