-
Notifications
You must be signed in to change notification settings - Fork 689
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: EXPOSED-472 Alias IdTable fails with isNull and eq ops #2189
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
toCompare: Any?, | ||
operator: (Column<*>, Expression<*>) -> Op<Boolean>, | ||
): Op<Boolean> { | ||
return when (delegate) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would use =
instead of return here and eliminate inner returns to simplify reading
@Suppress("UNCHECKED_CAST") | ||
override fun mapIdComparison( | ||
toCompare: Any?, | ||
operator: (Column<*>, Expression<*>) -> Op<Boolean>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
operator is a keyword (soft), please consider using other name
02e020d
to
4ba7724
Compare
The introduction of `CompositeIdTable`, and functions like `mapIdComparison` an> `mapIdOperator`, led to a regression. When any `IdTable` is aliased and used wi> the affected comparison operators, `eq` and `isNull` (and negative variants), the following is thrown: org.jetbrains.exposed.sql.Alias cannot be cast to org.jetbrains.exposed.dao.id.> The aliased `idColumns` of the `Alias` delegate need to be used in these functi> so these internal functions have been brought a level down, into the `Table` cl> so they can be overridden in `Alias` as well. `Alias.get()` operator has also been fixed to allow `CompositeIdTable` to be al> and still access the delegate `id` column properly.
- Change Alias override internal return to function = operator - Rename both internal function parameters to booleanOperator instead of operator
- Rebase from main - Remove unecessary cast
4ba7724
to
6e0553c
Compare
Description
Summary of the change: Using any aliased
IdTable
withisNull()
oreq()
no longer throws a class cast exception.Detailed description:
Why:
The introduction of
CompositeIdTable
(PR feat: EXPOSED-77 Support entity class for table with composite primary key #1987 ), and internal functionsmapIdComparison
andmapIdOperator
, led to a regression. When anyIdTable
is aliased and used with the associated comparison operators,eq
andisNull
(and negative variants), the following is thrown:org.jetbrains.exposed.sql.Alias cannot be cast to org.jetbrains.exposed.dao.id.IdTable
What:
The
Alias
class now has its own override for these internal functions, so that the aliasedidColumns
of the delegate are used.How:
mapIdComparison
andmapIdOperator
have been moved a level down toTable
, so that they can be overridden byAlias
as well, which is a subclass too.Alias.get()
operator has also been fixed to allowCompositeIdTable
to be aliased and still access the delegateid
column properly.Type of Change
Please mark the relevant options with an "X":
Affected databases:
Checklist
Related Issues
EXPOSED-472