Skip to content

Commit

Permalink
Rework resolving auto increment type to handle own ColumnType impleme…
Browse files Browse the repository at this point in the history
…ntation (#663)
  • Loading branch information
sledzmateusz authored and Tapac committed Oct 26, 2019
1 parent 6257f17 commit 934077a
Showing 1 changed file with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,13 @@ class AutoIncColumnType(val delegate: ColumnType, private val _autoincSeq: Strin
is EntityIDColumnType<*> -> resolveAutIncType(columnType.idColumn.columnType)
is IntegerColumnType -> currentDialect.dataTypeProvider.integerAutoincType()
is LongColumnType -> currentDialect.dataTypeProvider.longAutoincType()
else -> error("Unsupported type $delegate for auto-increment")
else -> guessAutIncTypeBy(columnType.sqlType())
} ?: error("Unsupported type $delegate for auto-increment")

private fun guessAutIncTypeBy(sqlType: String) : String? = when (sqlType) {
currentDialect.dataTypeProvider.longType() -> currentDialect.dataTypeProvider.longAutoincType()
currentDialect.dataTypeProvider.integerType() -> currentDialect.dataTypeProvider.integerAutoincType()
else -> null
}

override fun sqlType(): String = resolveAutIncType(delegate)
Expand Down

0 comments on commit 934077a

Please sign in to comment.