Skip to content

Commit

Permalink
[JetBrains/Exposed] SQLite autoincrement columns are not created (#669)…
Browse files Browse the repository at this point in the history
… / code cleanup #2
  • Loading branch information
Tapac committed Nov 3, 2019
1 parent 85c1327 commit 2585ae6
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/Column.kt
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,10 @@ class Column<T>(val table: Table, val name: String, override val columnType: ICo
val colType = columnType
val isSQLiteAutoIncColumn = currentDialect is SQLiteDialect && colType.isAutoInc

if (!isPKColumn && isSQLiteAutoIncColumn) {
tr.throwUnsupportedException("Auto-increment could be applied only to primary key column")// Workaround as SQLite Doesn't support both PK and autoInc in DDL
}

if (isSQLiteAutoIncColumn && !isOneColumnPK() && table.columns.any{ it.indexInPK != null}) {
append(currentDialect.dataTypeProvider.integerType()) // Workaround as SQLite Doesn't support both PK and autoInc in DDL
} else {
append(colType.sqlType())
when {
!isPKColumn && isSQLiteAutoIncColumn -> tr.throwUnsupportedException("Auto-increment could be applied only to primary key column")
isSQLiteAutoIncColumn && !isOneColumnPK() && table.columns.any{ it.indexInPK != null} -> append(currentDialect.dataTypeProvider.integerType())
else -> append(colType.sqlType())
}

val _dbDefaultValue = dbDefaultValue
Expand Down

0 comments on commit 2585ae6

Please sign in to comment.