JetBrains / JetBrains/Exposed

Set autoincrement and unique index fails

Open
#1,314 2 comments 1 reaction 0 assignees View on GitHub
Dominant language
Kotlin
Stars
9.3k
Forks
798
Avg merge
4d 2h
Merged PRs (30d)
26

Description

Maybe i'm wrong but setting a column like:
long("ordernumber").uniqueIndex().autoIncrement()

should be fine in case of Mysql. In newer versions its allowed to have a autoincrement column without the constraint of haveing it to be the primary key.

I got the following error:
```
org.jetbrains.exposed.exceptions.ExposedSQLException: java.sql.SQLSyntaxErrorException: Incorrect table definition; there can be only one auto column and it must be defined as a key
SQL: [CREATE TABLE IF NOT EXISTS good (id BINARY(16) PRIMARY KEY, active BOOLEAN NOT NULL, code VARCHAR(20) NOT NULL, description VARCHAR(255) NOT NULL, externalcode VARCHAR(30) NOT NULL, ordernumber BIGINT AUTO_INCREMENT NOT NULL)]
```

I not even see the unique Index there....

Using exposed : 0.32.1 with jdbc for mysql

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.