object BuddyTable: IdTable<Int>("toh.buddy"){
override val id = integer("id").autoIncrement("toh.buddy_seq_id").entityId()
val name = varchar("name", 50)
val hero = reference("hero_id", HeroTable)
}
class BuddyDao(id: EntityID<Int>) : IntEntity(id) {
companion object : IntEntityClass<BuddyDao>(BuddyTable)
var name by BuddyTable.name
var hero by HeroDao referencedOn BuddyTable.hero
}
override fun save(entity: Buddy): Int = transaction {
BuddyTable.insert {
it[name] = entity.name
it[hero] = entity.hero.id
}[BuddyTable.id].value
}
In postgres it looks like it is not using the sequence to generate the new id (also if i don't override the id field)
Prefixing or not with the schema "toh" doesn't change.
The error is
ah ok... looking at the code I thought it should already work
Luca Piccinelli
04/24/2021, 2:04 PM
there exist a workaround to use autoincrement with postgres?
Luca Piccinelli
04/25/2021, 5:17 AM
sorry, in my case it was my fault, not a bug. In the test I was assigning the ids manually (then the sequence didn't get incremented), while in the repository I was using the sequence.