Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions documentation-website/Writerside/topics/Breaking-Changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Breaking Changes

## 1.0.0-rc-5

* The interface `R2dbcPreparedStatementApi` no longer holds the unused methods `closeIfPossible()` or `cancel()`
as there are no relevant matching methods available for `io.r2dbc.spi.Statement`, in the same way as there are for
JDBC's `java.sql.PreparedStatement`. Any resource cleanup logic that may have been implemented via these methods can
still be implemented by `GlobalStatementInterceptor.afterStatementPrepared()`.
* `R2dbcTransaction.closeExecutedStatements()` has been renamed to `.clearExecutedStatements()` to better relay it's actual
behavior. It no longer invokes the now-removed method `R2dbcPreparedStatementApi.closeIfPossible()` & no longer suspends.

## 1.0.0-rc-4

* If H2 version 2.4.240+ is detected, `datetime()` column type will now map to type `TIMESTAMP(9)` in the following modes:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ class UserCreatedTransactionsTests : R2dbcDatabaseTestsBase() {

@OptIn(InternalApi::class)
@Test
fun testCloseExecutedStatements() {
fun testClearExecutedStatements() {
withConnection(dialect) { db, testDb ->
val tx = TransactionManager.currentOrNew()

Expand All @@ -144,7 +144,7 @@ class UserCreatedTransactionsTests : R2dbcDatabaseTestsBase() {
assertEquals(1, result?.size)
assertEquals(100, result?.get(0))

tx.closeExecutedStatements()
tx.clearExecutedStatements()

tx.close()
}
Expand Down
6 changes: 1 addition & 5 deletions exposed-r2dbc/api/exposed-r2dbc.api
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,8 @@ public class org/jetbrains/exposed/v1/r2dbc/R2dbcTransaction : org/jetbrains/exp
public static final field Companion Lorg/jetbrains/exposed/v1/r2dbc/R2dbcTransaction$Companion;
public fun <init> (Lorg/jetbrains/exposed/v1/r2dbc/transactions/R2dbcTransactionInterface;)V
public final fun addLogger ([Lorg/jetbrains/exposed/v1/core/SqlLogger;)Lorg/jetbrains/exposed/v1/core/CompositeSqlLogger;
public final fun clearExecutedStatements ()V
public fun close (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun closeExecutedStatements (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun commit (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun connection (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public final fun exec (Ljava/lang/String;Ljava/lang/Iterable;Lorg/jetbrains/exposed/v1/core/statements/StatementType;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -752,8 +752,6 @@ public final class org/jetbrains/exposed/v1/r2dbc/statements/R2dbcConnectionImpl
public final class org/jetbrains/exposed/v1/r2dbc/statements/R2dbcPreparedStatementImpl : org/jetbrains/exposed/v1/r2dbc/statements/api/R2dbcPreparedStatementApi {
public fun <init> (Lio/r2dbc/spi/Statement;Lio/r2dbc/spi/Connection;ZLorg/jetbrains/exposed/v1/core/vendors/DatabaseDialect;Lorg/jetbrains/exposed/v1/r2dbc/mappers/R2dbcTypeMapping;)V
public fun addBatch (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun closeIfPossible (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun executeBatch (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun executeMultiple (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public fun executeQuery (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down Expand Up @@ -969,8 +967,6 @@ public final class org/jetbrains/exposed/v1/r2dbc/statements/api/R2dbcLocalMetad

public abstract interface class org/jetbrains/exposed/v1/r2dbc/statements/api/R2dbcPreparedStatementApi : org/jetbrains/exposed/v1/core/statements/api/PreparedStatementApi {
public abstract fun addBatch (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun cancel (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun closeIfPossible (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun executeBatch (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun executeMultiple (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
public abstract fun executeQuery (Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,11 +315,9 @@ open class R2dbcTransaction(
internal suspend fun execQuery(query: SuspendExecutable<ResultApi, *>): R2dbcResult = execQuery(query) { it }
?: error("A R2dbcResult was expected, but a result was not retrieved from the database")

/** Closes all previously executed statements and resets or releases any used database and/or driver resources. */
suspend fun closeExecutedStatements() {
executedStatements.forEach {
it.closeIfPossible()
}
/** Clears all previously executed statements and resets or releases any used database and/or driver resources. */
fun clearExecutedStatements() {
// no Statement.close() in R2DBC
openResultRowsCount = 0
executedStatements.clear()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,6 @@ class R2dbcPreparedStatementImpl(
throw IllegalArgumentException("Unsupported array type: ${type::class.qualifiedName}")
}

override suspend fun closeIfPossible() {
// do nothing
}

override suspend fun executeBatch(): List<Int> {
val result = statement.execute()
val r2dbcResult = R2dbcResult(result, typeMapping)
Expand All @@ -152,8 +148,4 @@ class R2dbcPreparedStatementImpl(
r2dbcResult.rowsUpdated().toList()
}
}

override suspend fun cancel() {
// do nothing
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ internal suspend fun <T, S : Statement<T>> SuspendExecutable<T, S>.executeIn(
if (isNotLastItemInTheBatch && (contexts.size > 1 || isAlwaysBatch)) statement.addBatch()
}
if (!transaction.db.supportsMultipleResultSets) {
transaction.closeExecutedStatements()
transaction.clearExecutedStatements()
}

transaction.currentStatement = statement
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,11 @@ interface R2dbcPreparedStatementApi : PreparedStatementApi {
/** The [R2dbcResult] generated by the executed statement, or `null` if none was retrieved. */
suspend fun getResultRow(): R2dbcResult?

/** Closes the statement, if still open, and releases any of its database and/or driver resources. */
suspend fun closeIfPossible()

/**
* Executes batched SQL statements stored as an [io.r2dbc.spi.Statement].
*
* @return A list of the affected row counts, with one element for each statement,
* ordered based on the order in which statements were provided to the batch.
*/
suspend fun executeBatch(): List<Int>

/** Cancels the statement, if supported by the database. */
suspend fun cancel()
}
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,10 @@ internal suspend fun handleR2dbcException(cause: R2dbcException, transaction: R2
}

/**
* Closes all statements and the connection associated with a transaction.
* Clears all statements and closes the connection associated with a transaction.
*
* This function ensures proper cleanup of resources by closing the current statement,
* all executed statements, and the transaction connection. Any exceptions during cleanup are logged.
* This function ensures proper cleanup of resources by clearing the current statement,
* all executed statements, and closing the transaction connection. Any exceptions during cleanup are logged.
*
* @param transaction The transaction whose resources should be closed.
*/
Expand All @@ -270,10 +270,10 @@ internal suspend fun closeStatementsAndConnection(transaction: R2dbcTransaction)
@Suppress("TooGenericExceptionCaught")
try {
currentStatement?.let {
it.closeIfPossible()
// no Statement.close() in R2DBC
transaction.currentStatement = null
}
transaction.closeExecutedStatements()
transaction.clearExecutedStatements()
} catch (cause: Exception) {
exposedLogger.warn("Statements close failed", cause)
}
Expand Down
Loading