diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt index b388721acf..56981b6b52 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Table.kt @@ -539,10 +539,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")