Skip to content

Commit

Permalink
#385 autoIncrement carries to referencing column
Browse files Browse the repository at this point in the history
  • Loading branch information
Tapac committed Sep 12, 2018
1 parent c4b08ab commit 8f798b9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/kotlin/org/jetbrains/exposed/sql/Table.kt
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,9 @@ open class Table(name: String = ""): ColumnSet(), DdlAware {
entityId(name, foreign).references(foreign.id, onDelete, onUpdate)

fun<T> Table.reference(name: String, pkColumn: Column<T>): Column<T> {
val column = Column<T>(this, name, pkColumn.columnType) references pkColumn
val originalType = (pkColumn.columnType as? EntityIDColumnType<*>)?.idColumn?.columnType ?: pkColumn.columnType
val columnType = originalType.let { (it as? AutoIncColumnType)?.delegate ?: it}.clone()
val column = Column<T>(this, name, columnType) references pkColumn
this._columns.add(column)
return column
}
Expand Down

0 comments on commit 8f798b9

Please sign in to comment.