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
If column doesn't have default value and value of column is not set to BatchInsertStatement, the exception BatchDataInconsistentException should be thrown from org.jetbrains.exposed.sql.statements.BatchInsertStatement#validateLastBatch if requiredInTargets is not empty.
However now the exception always says java.util.NoSuchElementException: List is empty.
List is empty.
java.util.NoSuchElementException: List is empty.
at kotlin.collections.CollectionsKt___CollectionsKt.last(_Collections.kt:362)
at org.jetbrains.exposed.sql.statements.BatchInsertStatement.allColumnsInDataSet(BatchInsertStatement.kt:59)
at org.jetbrains.exposed.sql.statements.BatchInsertStatement.getArguments(BatchInsertStatement.kt:63)
at org.jetbrains.exposed.sql.statements.InsertStatement.arguments(InsertStatement.kt:147)
at org.jetbrains.exposed.sql.QueriesKt.batchInsert(Queries.kt:128)
I think fun BatchInsertStatement.handleBatchException in org.jetbrains.exposed.sql.batchInsert is hiding the real error.
Test case:
data classEntity(
valexist:String = "anything"
)
object TestTable : Table() {
val id = integer("i").autoIncrement().primaryKey()
val exist = varchar("e", 9)
val notExist = varchar("n", 9)
}
funtest() {
transaction {
SchemaUtils.create(TestTable)
TestTable.apply {
// This will pass
batchInsert(listOf(Entity())) { this[exist] = it.exist; this[notExist] ="whatever" }.map { println(it[id]) }
// This throws irrelevant exception
batchInsert(listOf(Entity())) { this[exist] = it.exist }.map { println(it[id]) }
}
}
}
The text was updated successfully, but these errors were encountered:
My client app got "List is empty" exception from an API. I thought that should be a business logic error because list operations were commonly used in project. However after I traced all codes, I found it was from Exposed library, due to a wrong table was accidentally used.
It would be easier to debug if original BatchDataInconsistentException is thrown with message.
If column doesn't have default value and value of column is not set to
BatchInsertStatement
, the exceptionBatchDataInconsistentException
should be thrown fromorg.jetbrains.exposed.sql.statements.BatchInsertStatement#validateLastBatch
ifrequiredInTargets
is not empty.However now the exception always says
java.util.NoSuchElementException: List is empty
.I think
fun BatchInsertStatement.handleBatchException
inorg.jetbrains.exposed.sql.batchInsert
is hiding the real error.Test case:
The text was updated successfully, but these errors were encountered: