Skip to content

Commit

Permalink
#270 Add support for check constraints. / Fixed that table name can't…
Browse files Browse the repository at this point in the history
… be used in check condition #2
  • Loading branch information
Tapac committed Jun 5, 2018
1 parent fb46284 commit 873a4e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/kotlin/org/jetbrains/exposed/sql/Constraints.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@ data class CheckConstraint(val tableName: String, val checkName: String, val che
internal fun from(table: Table, name: String, op: Op<Boolean>): CheckConstraint {
require(name.isNotBlank())
val tr = TransactionManager.current()
return CheckConstraint(tr.identity(table), tr.quoteIfNecessary(name), op.toSQL(QueryBuilder(false)))
val tableName = tr.identity(table)
val checkOpSQL = op.toSQL(QueryBuilder(false)).replace("$tableName.","")
return CheckConstraint(tableName, tr.quoteIfNecessary(name), checkOpSQL)
}
}

Expand Down

0 comments on commit 873a4e3

Please sign in to comment.