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 has_closure_tree_roots (plural) to allow has_many in related AR models #446

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

Conversation

sergioisidoro
Copy link

Having has_closure_tree_root is quite useful, when there is a root instance that collects all children.

However I have the use case where a related model has multiple roots. This is not a case of multi-parent hierarchy, but instead a related object having multiple roots. The example in the tests is one of them. Post has many comments, and those comments can have children. With has_closure_tree_root we would be forced to create a root comment to each post, from which all members would be decendents from to use the query helpers.

This allows a related model to have multiple associated roots, and have the same perfomance boost in the queries as with the has_closure_tree_root..

NOTE I was assisted by an AI agent while doing this work, and some of the code here is generated by a model. It has been reviewed and iterated by me.

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.

1 participant