Skip to content

Commit

Permalink
deprecate: Raise deprecation levels of API elements (#2208)
Browse files Browse the repository at this point in the history
The following elements had most recent level change in release 0.46.0 (January 2024).

Raise from WARNING to ERROR:
- FieldSet.select(where)
- FieldSet.selectBatched()
- FieldSet.selectAllBatched()
- Query.adjustSlice()
- ColumnSet.slice()

The following elements had most recent level change in release 0.50.0 (April 2024).

Raise from WARNING to ERROR:
- Database.connectPool()
- DatabaseConfig.defaultRepetitionAttempts and Transaction.repetitionAttempts
- DatabaseConfig.defaultMinRepetitionDelay and Transaction.minRepetitionDelay
- DatabaseConfig.defaultMaxRepetitionDelay and Transaction.maxRepetitionDelay

Currently HIDDEN, now removed:
- ExposedDatabaseMetadata interface property currentScheme

Additional:
The original buildSrc/Versions object was also raised to ERROR in release 0.50.0
(April 2024). It has now been removed.
  • Loading branch information
bog-walk committed Aug 20, 2024
1 parent c6a035f commit ade2a16
Show file tree
Hide file tree
Showing 14 changed files with 26 additions and 121 deletions.
27 changes: 0 additions & 27 deletions buildSrc/src/main/kotlin/org/jetbrains/exposed/gradle/Versions.kt

This file was deleted.

1 change: 0 additions & 1 deletion exposed-core/api/exposed-core.api
Original file line number Diff line number Diff line change
Expand Up @@ -3461,7 +3461,6 @@ public abstract class org/jetbrains/exposed/sql/statements/api/ExposedDatabaseMe
public abstract fun columns ([Lorg/jetbrains/exposed/sql/Table;)Ljava/util/Map;
public abstract fun existingIndices ([Lorg/jetbrains/exposed/sql/Table;)Ljava/util/Map;
public abstract fun existingPrimaryKeys ([Lorg/jetbrains/exposed/sql/Table;)Ljava/util/Map;
public abstract synthetic fun getCurrentScheme ()Ljava/lang/String;
public final fun getDatabase ()Ljava/lang/String;
public abstract fun getDatabaseDialectName ()Ljava/lang/String;
public abstract fun getDatabaseProductVersion ()Ljava/lang/String;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
val defaultRepetitionAttempts: Int,
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMinRetryDelay"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
val defaultMinRepetitionDelay: Long,
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxRetryDelay"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
var defaultMaxRepetitionDelay: Long
get() = defaultMaxRetryDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ 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.WARNING
level = DeprecationLevel.ERROR
)
inline fun FieldSet.select(where: SqlExpressionBuilder.() -> Op<Boolean>): Query = Query(this, SqlExpressionBuilder.where())

Expand All @@ -26,7 +26,7 @@ inline fun Query.select(where: SqlExpressionBuilder.() -> Op<Boolean>): Query =
@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.WARNING
level = DeprecationLevel.ERROR
)
fun FieldSet.select(where: Op<Boolean>): Query = Query(this, where)

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.WARNING
level = DeprecationLevel.ERROR
)
fun FieldSet.selectBatched(
batchSize: Int = 1000,
Expand All @@ -80,7 +80,7 @@ fun Query.selectBatched(
"selectAll().fetchBatchedResults(batchSize)",
"import org.jetbrains.exposed.sql.selectAll"
),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
fun FieldSet.selectAllBatched(
batchSize: Int = 1000
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
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.WARNING
level = DeprecationLevel.ERROR
)
var maxRepetitionDelay: Long
get() = maxRetryDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,6 @@ abstract class ExposedDatabaseMetadata(val database: String) {
/** Whether the database supports `SELECT FOR UPDATE` statements. */
abstract val supportsSelectForUpdate: Boolean

@Deprecated(
message = "it's temporary solution which will be replaced in a future releases. Do not use it in your code",
level = DeprecationLevel.HIDDEN
)
abstract val currentScheme: String

/** Clears and resets any stored information about the database's current schema to default values. */
abstract fun resetCurrentScheme()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ThreadLocalTransactionManager(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxAttempts"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
override var defaultRepetitionAttempts: Int
get() = defaultMaxAttempts
Expand All @@ -43,7 +43,7 @@ class ThreadLocalTransactionManager(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMinRetryDelay"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
override var defaultMinRepetitionDelay: Long
get() = defaultMinRetryDelay
Expand All @@ -52,7 +52,7 @@ class ThreadLocalTransactionManager(
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxRetryDelay"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
override var defaultMaxRepetitionDelay: Long
get() = defaultMaxRetryDelay
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ private object NotInitializedManager : TransactionManager {

override var defaultMaxRetryDelay: Long = 0

@Deprecated("This will be removed when the interface property is fully deprecated", level = DeprecationLevel.WARNING)
@Deprecated("This will be removed when the interface property is fully deprecated", level = DeprecationLevel.ERROR)
override var defaultRepetitionAttempts: Int = -1

@Deprecated("This will be removed when the interface property is fully deprecated", level = DeprecationLevel.WARNING)
@Deprecated("This will be removed when the interface property is fully deprecated", level = DeprecationLevel.ERROR)
override var defaultMinRepetitionDelay: Long = 0

@Deprecated("This will be removed when the interface property is fully deprecated", level = DeprecationLevel.WARNING)
@Deprecated("This will be removed when the interface property is fully deprecated", level = DeprecationLevel.ERROR)
override var defaultMaxRepetitionDelay: Long = 0

override fun newTransaction(isolation: Int, readOnly: Boolean, outerTransaction: Transaction?): Transaction =
Expand Down Expand Up @@ -87,21 +87,21 @@ interface TransactionManager {
@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxAttempts"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
var defaultRepetitionAttempts: Int

@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMinRetryDelay"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
var defaultMinRepetitionDelay: Long

@Deprecated(
message = "This property will be removed in future releases",
replaceWith = ReplaceWith("defaultMaxRetryDelay"),
level = DeprecationLevel.WARNING
level = DeprecationLevel.ERROR
)
var defaultMaxRepetitionDelay: Long

Expand Down
1 change: 0 additions & 1 deletion exposed-jdbc/api/exposed-jdbc.api
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public final class org/jetbrains/exposed/sql/statements/jdbc/JdbcDatabaseMetadat
public fun columns ([Lorg/jetbrains/exposed/sql/Table;)Ljava/util/Map;
public fun existingIndices ([Lorg/jetbrains/exposed/sql/Table;)Ljava/util/Map;
public fun existingPrimaryKeys ([Lorg/jetbrains/exposed/sql/Table;)Ljava/util/Map;
public synthetic fun getCurrentScheme ()Ljava/lang/String;
public fun getDatabaseDialectName ()Ljava/lang/String;
public fun getDatabaseProductVersion ()Ljava/lang/String;
public fun getDefaultIsolationLevel ()I
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,6 @@ class JdbcDatabaseMetadataImpl(database: String, val metadata: DatabaseMetaData)
return field!!
}

@Deprecated(
message = "This will be removed when the interface property is fully deprecated",
level = DeprecationLevel.HIDDEN
)
override val currentScheme: String get() = currentSchema!!

override fun resetCurrentScheme() {
currentSchema = null
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jetbrains.exposed.sql.tests.shared.dml

import nl.altindag.log.LogCaptor
import org.jetbrains.exposed.dao.id.IntIdTable
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.tests.DatabaseTestsBase
Expand All @@ -9,62 +8,9 @@ import org.jetbrains.exposed.sql.tests.shared.assertEquals
import org.jetbrains.exposed.sql.tests.shared.entities.EntityTests
import org.jetbrains.exposed.sql.tests.shared.expectException
import org.junit.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertNull

class SelectTests : DatabaseTestsBase() {
@Test
fun testMigrationToNewQueryDSL() {
withCitiesAndUsers { cities, _, _ ->
val logCaptor = LogCaptor.forName(exposedLogger.name)
logCaptor.setLogLevelToDebug()

// old query dsl
cities.slice(cities.name).select { cities.name eq "andrey" }.toList()
cities.slice(cities.name).select(Op.TRUE).toList()
cities.slice(cities.name).selectAll().toList()

cities.select { cities.name eq "andrey" }.toList()
cities.select(Op.TRUE).toList()
cities.selectAll().toList()

cities.slice(cities.name).selectBatched(50) { cities.name eq "andrey" }.toList()
cities.slice(cities.name).selectAllBatched(50).toList()
cities.selectBatched(50) { cities.name eq "andrey" }.toList()
cities.selectAllBatched(50).toList()

val originalQuery1 = cities.select { cities.name eq "andrey" }.also { it.toList() }
originalQuery1.adjustSlice { slice(cities.name) }.toList()

val sqlLoggedWithOldDSL = logCaptor.debugLogs.toList()
logCaptor.clearLogs()

// new query dsl
cities.select(cities.name).where { cities.name eq "andrey" }.toList()
cities.select(cities.name).where(Op.TRUE).toList()
cities.select(cities.name).toList()

cities.selectAll().where { cities.name eq "andrey" }.toList()
cities.selectAll().where(Op.TRUE).toList()
cities.selectAll().toList()

cities.select(cities.name).where { cities.name eq "andrey" }.fetchBatchedResults(50).toList()
cities.select(cities.name).fetchBatchedResults(50).toList()
cities.selectAll().where { cities.name eq "andrey" }.fetchBatchedResults(50).toList()
cities.selectAll().fetchBatchedResults(50).toList()

val originalQuery2 = cities.selectAll().where { cities.name eq "andrey" }.also { it.toList() }
originalQuery2.adjustSelect { select(cities.name) }.toList()

val sqlLoggedWithNewDSL = logCaptor.debugLogs.toList()
logCaptor.clearLogs()
logCaptor.resetLogLevel()
logCaptor.close()

assertContentEquals(sqlLoggedWithOldDSL, sqlLoggedWithNewDSL)
}
}

@Test
fun testSelect() {
withCitiesAndUsers { _, users, _ ->
Expand Down

0 comments on commit ade2a16

Please sign in to comment.