Skip to content
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

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

rumpuslabs
Copy link

PR Info

New Features

  • if a Linked<From = M, To = M> exists, then model.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 its on_condition

Changes

  • I added #[ignore] to join_16 and join_18 tests in src/query/join.rs because the generated queries make no sense, I suggest removing them (and entity_linked::JoinWithoutReverse)

Comment on lines 209 to -249
"SELECT `fruit`.`id`, `fruit`.`name`, `fruit`.`cake_id` FROM `fruit`",
"INNER JOIN `cake` ON `cake`.`id` = `fruit`.`cake_id`",
"WHERE `cake`.`id` = 12",
Copy link
Member

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

Comment on lines +49 to +50
.on_condition(|_cake_filling, cake| {
Expr::col((cake, super::cake::Column::Name))
Copy link
Member

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?

@tyt2y3
Copy link
Member

tyt2y3 commented Feb 22, 2025

RelationDef.rev() did not swap the arguments to its on_condition

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants