https://kotlinlang.org logo
#exposed
Title
# exposed
t

than_

11/01/2021, 1:23 PM
I've found weird transaction behaviour on MYSQL. having
Copy code
object TransactionTestTable: LongIdTable(){
    val foo = integer("foo").check { it greater 0 }
}
when I do
Copy code
newSuspendedTransaction {
    TransactionTestTable.insert { it[foo] = 1 }
    throw IllegalStateException("FAIL")
}
the transaction performs a rollback correctly and nothing gets inserted into the table but when I do
Copy code
newSuspendedTransaction {
    TransactionTestTable.insert { it[foo] = 1 }
    TransactionTestTable.insert { it[foo] = 0 }
}
the transaction still fails, but the first value gets inserted in the database. Is this intentional or a bug?
b

benkuly

12/16/2021, 7:45 AM
I have exactly the same problem. It seems that
newSuspendedTransaction
always commits at end and don't uses the parent transaction.
here is a link to the issue
problem was
useLocalTransactionState
set to
true
when disabled, this problem dissapeared
👍 1
b

benkuly

12/16/2021, 10:24 AM
and where can I find this property in exposed?
t

than_

12/16/2021, 10:56 AM
you'd have to set it not in exposed but in your connector
if you use hikari they expose it in their configuration as well