-
-
Notifications
You must be signed in to change notification settings - Fork 558
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
Add find_linked_recursive method to ModelTrait #2480
base: master
Are you sure you want to change the base?
Conversation
…necessary joins in ModelTrait
"SELECT `fruit`.`id`, `fruit`.`name`, `fruit`.`cake_id` FROM `fruit`", | ||
"INNER JOIN `cake` ON `cake`.`id` = `fruit`.`cake_id`", | ||
"WHERE `cake`.`id` = 12", |
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.
Oh wow this is such a smart optimization
.on_condition(|_cake_filling, cake| { | ||
Expr::col((cake, super::cake::Column::Name)) |
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.
why is the left and right swapped?
I understand your point that this is a bug, but this will be a breaking change to fix this at this point, sadly. Can you add some test cases to demonstrate the recursive use cases? |
PR Info
New Features
Linked<From = M, To = M>
exists, thenmodel.find_linked_recursive
will generate a CTE to follow the links recursively and return all ancestors or descendants of the model.Bug Fixes
RelationDef.rev()
did not swap the arguments to itson_condition
Changes
#[ignore]
tojoin_16
andjoin_18
tests insrc/query/join.rs
because the generated queries make no sense, I suggest removing them (andentity_linked::JoinWithoutReverse
)