zt
02/16/2022, 2:52 AMGuild.update({ Guild.id eq guild.id.toString() }) {
it[data] = data + "abc"
}
For some reason, it always sets the value to "0"
The table is defined like this
object Guild : Table() {
val id = varchar("id", 18)
val data = text("data").default("")
override val primaryKey = PrimaryKey(id)
}
If I use it[data] = "whatever"
then it actually sets to the proper valuedave08
02/16/2022, 4:07 AMzt
02/16/2022, 5:05 AMspand
02/16/2022, 10:23 AMwith(SqlExpressionBuilder) {
as the example iszt
02/16/2022, 3:45 PMBogdan
02/17/2022, 4:44 PMFeature not supported: "CLOB +"; SQL statement:
UPDATE GUILD SET "DATA"=(GUILD."DATA" + '1') WHERE GUILD.ID = '1'
Guild.update({ Guild.id eq guildId }) {
it[value] = value + 1 // work, import org.jetbrains.exposed.sql.SqlExpressionBuilder.plus
with(SqlExpressionBuilder) {
it[value] = value + 1 // work
// it[data] = data + "1" not work, error
it[data] = concat(data, stringLiteral("123"))
}
}
value = integer
log:
SQL: UPDATE GUILD SET "VALUE"=(GUILD."VALUE" + 1), "DATA"=CONCAT(GUILD."DATA", '123') WHERE GUILD.ID = '1'
com.example.Guild.id=1, com.example.Guild.data=clob1: 'data123', com.example.Guild.value=1
import org.jetbrains.exposed.sql.*
import org.jetbrains.exposed.sql.SqlExpressionBuilder.concat
import org.jetbrains.exposed.sql.SqlExpressionBuilder.plus // +
import org.jetbrains.exposed.sql.transactions.transaction
fun main() {
// transaction
Guild.update({ Guild.id eq guildId }) {
it[value] = value + 1
it[data] = concat(data, stringLiteral("123"))
}
object Guild : Table() {
val id = varchar("id", 18)
val data = text("data").default("")
val value = integer("value").default(0)
override val primaryKey = PrimaryKey(id)
}
zt
02/17/2022, 6:34 PM