diff --git a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt index 376b66d9ca..dbc93be5c0 100644 --- a/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt +++ b/exposed-core/src/main/kotlin/org/jetbrains/exposed/sql/SQLExpressionBuilder.kt @@ -148,8 +148,8 @@ interface ISqlExpressionBuilder { } /** Checks if this expression is equals to some [other] expression. */ - infix fun Expression.eq(other: Expression): Op = when { - other.equals(Op.NULL) -> isNull() + infix fun Expression.eq(other: Expression): Op = when (other as Expression<*>) { + is Op.NULL -> isNull() else -> EqOp(this, other) } diff --git a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt index 08876116e8..8a176f4466 100644 --- a/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt +++ b/exposed-tests/src/test/kotlin/org/jetbrains/exposed/sql/tests/shared/DDLTests.kt @@ -686,6 +686,19 @@ class DDLTests : DatabaseTestsBase() { } } + @Test + fun testCheckConstraint03() { + object : Table("test") { + val testColumn: Column = integer("test_column").nullable() + + init { + check("test_constraint") { + testColumn.isNotNull() eq Op.TRUE + } + } + } + } + internal enum class Foo { Bar, Baz } class PGEnum>(enumTypeName: String, enumValue: T?) : PGobject() {