Ruckus
08/02/2023, 5:07 PMorg.jetbrains.exposed.exceptions.ExposedSQLException: org.h2.jdbc.JdbcSQLDataException: Data conversion error converting "��&��E��B-\000a�\000b!�";
More info in 🧵Ruckus
08/02/2023, 5:09 PMobject HeaderTable : Table("header") {
val id = uuid("id").autoGenerate()
val type = varchar("type", TYPE_SIZE).nullable()
val isMulti = bool("multi").default(false)
val created = timestamp("created").defaultExpression(CurrentTimestamp())
val updated = timestamp("updated").defaultExpression(CurrentTimestamp())
override val primaryKey = PrimaryKey(id)
}
(the actual table is part of an inheritance hierarchy, but this is effectively what it amounts to)
And the upsert
statement is
HeaderTable.upsert { // <-- The error is pointing at this line
it[id] = header.id
it[title] = header.title
it[created] = header.created
it[updated] = header.updated
header.type?.let { ht ->
it[type] = encodeType(ht.type)
it[isMulti] = ht.type.isMulti
}
}
(created
and updated
are `java.time.Instant`s, and encodeType(...)
returns an string with only lowercase ASCII letters)Ruckus
08/02/2023, 5:48 PMupsert
. If I change to this, it works fine:
if (HeaderTable.findById(header.id) == null) {
HeaderTable.insert { setup(it, header) }
} else {
HeaderTable.update(
{ HeaderTable.id eq header.id }
) { setup(it, header) }
}
Where setup
is
fun HeaderTable.setup(it: UpdateBuilder<*>, header: Header) {
it[id] = header.id
it[title] = header.title
it[created] = header.created
it[updated] = header.updated
header.type?.let { ht ->
it[type] = encodeType(ht.type)
it[isMulti] = ht.type.isMulti
}
}
Ruckus
08/02/2023, 7:50 PMe5l
08/03/2023, 10:53 AM