From dfb63d26acc67ecb27a361b89dcc51f969d570c6 Mon Sep 17 00:00:00 2001 From: "Andrey.Tarashevskiy" Date: Mon, 14 Nov 2022 17:19:19 +0300 Subject: [PATCH] IsAutoCommit = false & transactionIsolation = "Transaction_Serializable" result in a PSQLException #1575 --- .../org/jetbrains/exposed/sql/statements/api/ExposedBlob.kt | 1 - .../sql/transactions/ThreadLocalTransactionManager.kt | 5 +++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/api/ExposedBlob.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/api/ExposedBlob.kt index 7c3b756e8c..5a12cf2197 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/api/ExposedBlob.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/statements/api/ExposedBlob.kt @@ -11,7 +11,6 @@ class ExposedBlob(val inputStream: InputStream) { if (this === other) return true if (other !is ExposedBlob) return false - if (!bytes.contentEquals(other.bytes)) return false return true diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt index 6b0b60b7fd..3745f69e80 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/transactions/ThreadLocalTransactionManager.kt @@ -75,11 +75,12 @@ class ThreadLocalTransactionManager( private val connectionLazy = lazy(LazyThreadSafetyMode.NONE) { outerTransaction?.connection ?: db.connector().apply { setupTxConnection?.invoke(this, this@ThreadLocalTransaction) ?: run { - // The order of `setReadOnly` and `setAutoCommit` is important. + // The order of setters here is important. + // Transaction isolation should go first as the readOnly or autoCommit can start transaction with wrong isolation level // Some drivers start a transaction right after `setAutoCommit(false)`, // which makes `setReadOnly` throw an exception if it is called after `setAutoCommit` - readOnly = this@ThreadLocalTransaction.readOnly transactionIsolation = this@ThreadLocalTransaction.transactionIsolation + readOnly = this@ThreadLocalTransaction.readOnly autoCommit = false } }