Skip to content

Commit

Permalink
A table column with .autoIncrement() and NO .primaryKey() does create…
Browse files Browse the repository at this point in the history
… primary key with SchemaUtils.createMissingTablesAndColumns() #649
  • Loading branch information
Tapac committed Nov 1, 2019
1 parent fce4a75 commit d3e8cde
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions exposed/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt
Original file line number Diff line number Diff line change
Expand Up @@ -553,10 +553,8 @@ open class Table(name: String = ""): ColumnSet(), DdlAware {
}

internal fun primaryKeyConstraint(): String? {
var pkey = columns.filter { it.indexInPK != null }.sortedWith(compareBy({ !it.columnType.isAutoInc }, { it.indexInPK }))
if (pkey.isEmpty()) {
pkey = columns.filter { it.columnType.isAutoInc }
}
val pkey = columns.filter { it.indexInPK != null }.sortedWith(compareBy({ !it.columnType.isAutoInc }, { it.indexInPK }))

if (pkey.isNotEmpty()) {
val tr = TransactionManager.current()
val constraint = tr.db.identifierManager.cutIfNecessaryAndQuote("pk_$tableName")
Expand Down

0 comments on commit d3e8cde

Please sign in to comment.