Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sequence is not used when specifying via autoIncrement #1209

Closed
simonnepomuk opened this issue Apr 16, 2021 · 1 comment
Closed

Sequence is not used when specifying via autoIncrement #1209

simonnepomuk opened this issue Apr 16, 2021 · 1 comment

Comments

@simonnepomuk
Copy link

I'm trying to create a table and the corresponding DAO like this:

object Roles: IdTable<Int>("roles") {
    override val id = integer("id").autoIncrement("role_id_seq").entityId()
    val name = varchar("name", 255)
}

class Role(id: EntityID<Int>) : IntEntity(id) {
    companion object : IntEntityClass<RoleKotlin>(Roles)
    var name by Roles.name
}

When I try to insert a new entity via transaction { Role.new { name = "new entity" } } I get the following exception:

Caused by: org.postgresql.util.PSQLException: ERROR: duplicate key value violates unique constraint "roles_pkey"
  Detail: Key (id)=(16) already exists.

I checked the sequence with select last_value from pg_sequences where sequencename like 'role_id_seq'; and the last value is 41.

Am I creating the Table or Entity in a wrong way or is this an issue with Exposed? Thanks in advance and feel free to contact me if you need any more info :)

@simonnepomuk simonnepomuk reopened this Apr 19, 2021
Tapac added a commit that referenced this issue Apr 19, 2021
…ects #492

Support sequences in SQL Server #1164
Sequence is not used when specifying via autoIncrement #1209
@Tapac Tapac closed this as completed Apr 20, 2021
SchweinchenFuntik pushed a commit to SchweinchenFuntik/Exposed that referenced this issue Oct 23, 2021
…ects JetBrains#492

Support sequences in SQL Server JetBrains#1164
Sequence is not used when specifying via autoIncrement JetBrains#1209
SchweinchenFuntik pushed a commit to SchweinchenFuntik/Exposed that referenced this issue Oct 23, 2021
@micHar
Copy link

micHar commented Apr 29, 2022

For anyone that wanders here somehow. Had this issue in 0.37.3, works fine in 0.38.2. Postgres

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants