You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
BatchUpdateStatement produces wrong SQL when the set(..) calls are not in alphabetical order for columns:
object Test : IntIdTable() {
val a = integer("a")
val b = float("b")
val c = text("c")
}
...
transaction {
addLogger(StdOutSqlLogger)
BatchUpdateStatement(Test).apply {
listOf(1).forEach {
addBatch(EntityID(it, Test))
this[Test.c] ="3"this[Test.a] =1this[Test.b] =2.0f
}
}.execute(this)
}
This produces: SQL: UPDATE TEST SET C=1, A=2.0, B='3' WHERE ID = 1
If the order is changed like this it works correctly:
org.jetbrains.exposed.sql.statements.BatchDataInconsistentException: Some values missing for batch update. Different columns: [Test.a, Test.b, Test.c]
Looking at the source code:
val different by lazy { data.first().second.keys.intersect(lastBatch!!.second.keys) }
This will make 'different' contain all keys on the third iteration.
jon-mey
changed the title
BatchUpdateStatement expects set(..) calls in alphabetical order
BatchUpdateStatement expects set(..) calls in alphabetical order and fails when given more than 2 batches
Sep 12, 2018
BatchUpdateStatement produces wrong SQL when the set(..) calls are not in alphabetical order for columns:
This produces:
SQL: UPDATE TEST SET C=1, A=2.0, B='3' WHERE ID = 1
If the order is changed like this it works correctly:
The text was updated successfully, but these errors were encountered: