Hildebrandt Tobias
02/20/2024, 1:21 PMye olden code is there no better
way to do this in exposed?
fun upsertTelegramFilter(filter: IbisTelegramFilterDTO) = transaction {
val exists = TelegramFilterTable
.select { TelegramFilterTable.id eq filter.id }
.singleOrNull() != null
if(exists)
TelegramFilterTable.update {
it[this.companyId] = filter.companyId
it[this.name] = filter.name
it[this.type] = filter.type
it[this.text] = filter.text
}
else
TelegramFilterTable.insert {
it[this.companyId] = filter.companyId
it[this.name] = filter.name
it[this.type] = filter.type
it[this.text] = filter.text
}
}Hildebrandt Tobias
02/20/2024, 6:59 PMHildebrandt Tobias
02/20/2024, 7:03 PMauto_increment.
Which makes me wonder, what is the behavior of your upsert on non-existing ids? Does it just omit the given ID and use the one according to the counter? Or does the ID for "inserts with upsert" must be 0 or something?Hildebrandt Tobias
02/21/2024, 5:28 PMHildebrandt Tobias
02/21/2024, 6:31 PMAxel
04/02/2024, 9:59 AM