Skip to content

Commit

Permalink
fix: EXPOSED-565 Subquery alias with id fails to use correct alias wi…
Browse files Browse the repository at this point in the history
…th eq

A fix for using mapIdComparison() with aliased table had been implemented, but
it did not fully cover the case when the right-hand side of the comparison involved
an unwrapped id column value. The latter was still using the delegate table associated
with the column type, instead of the invoking alias expression's alias table
identifier.
  • Loading branch information
bog-walk committed Sep 26, 2024
1 parent c1a24c9 commit 208ddce
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ interface ISqlExpressionBuilder {
val table = (columnType as EntityIDColumnType<*>).idColumn.table as IdTable<T>
val entityID = EntityID(t, table)
return if ((this as? Column<*>)?.isEntityIdentifier() == true) {
table.mapIdComparison(entityID, ::EqOp)
(this as Column<*>).table.mapIdComparison(entityID, ::EqOp)
} else {
EqOp(this, wrap(entityID))
}
Expand Down Expand Up @@ -382,7 +382,7 @@ interface ISqlExpressionBuilder {
val table = (columnType as EntityIDColumnType<*>).idColumn.table as IdTable<T>
val entityID = EntityID(t, table)
return if ((this as? Column<*>)?.isEntityIdentifier() == true) {
table.mapIdComparison(entityID, ::NeqOp)
(this as Column<*>).table.mapIdComparison(entityID, ::NeqOp)
} else {
NeqOp(this, wrap(entityID))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,11 @@ class AliasesTests : DatabaseTestsBase() {
counter[tester.id].isNotNull() and (counter[tester.id] eq t1)
}.single()
assertEquals(99, result2[counter[tester.amount]])

val result3 = counter.selectAll().where {
(counter[tester.id] eq t1.value) or (counter[tester.id] neq 123)
}.single()
assertEquals(99, result3[counter[tester.amount]])
}
}
}

0 comments on commit 208ddce

Please sign in to comment.