-
-
Notifications
You must be signed in to change notification settings - Fork 521
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 related & linked with enum columns #376
Conversation
Hey @MorganNesbitt, can you try this PR? You can update your toml sea-orm = { git = "https://github.com/SeaQL/sea-orm.git", branch = "issues/374", ... } |
Can briefly explain what's the root cause? |
hi @billy1624 that fixed the panic! One thing I did notice now that I have a join working, is that it adds an order by id no matter what. which seemed odd, and when you add an order to the query it doesn't replace it just puts it right after. A normal single query doesn't add an order, but the join does. is this expected? Below is what's being generated when I do a find_with_related but provide no order_by myself.
|
}, | ||
_ => panic!("cannot apply alias for expr other than Column"), |
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.
It panic at this line. It didn't catch ColumnRef::AsEnum
and apply alias for it.
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.
@@ -30,7 +30,7 @@ pub trait Linked { | |||
|
|||
select.query().join_as( | |||
JoinType::InnerJoin, | |||
unpack_table_ref(&rel.from_tbl), | |||
rel.from_tbl, |
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.
And I caught some other bug as well. This should pass the TableRef
in directly, so that schema name will also be included if needed.
@@ -79,21 +79,28 @@ where | |||
|
|||
slf.query().join_as( | |||
JoinType::LeftJoin, | |||
unpack_table_ref(&rel.to_tbl), | |||
rel.to_tbl, |
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.
And I caught some other bug as well. This should pass the TableRef in directly, so that schema name will also be included if needed.
Same here
That additional order by is intended. If you look into the implementation of sea-orm/src/executor/select.rs Lines 751 to 785 in 18ed683
(My explanation might be confusing loll) |
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.
Great thanks
PR Info