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

Allow alternative joining with WHERE IN for multiple plural joins #27

Open
jschreuder opened this issue May 3, 2011 · 0 comments
Open

Comments

@jschreuder
Copy link
Contributor

Adding multiple hasmany/many-many objects has the problem that it will multiply your output. Thus adding a relation with 3 objects to a single parent will return 1 x 3 objects. But adding another relation to your query with 5 objects makes it 1 x 3 x 5 = 15 rows for 9 objects. And it get progressively worse after that.

To solve this subsequent to-many relations could be fetching using an extra query:
SELECT .... FROM relation WHERE id IN (parent_id_1, parent_id_2, etc...)

What has to be figured out is how to configure this (seperate method from relation() or a flag in relation method second param array). The current get() method with the relation classes could probably be modified to work with plural objects as well.

It'll probably be a method named include() that includes a relation with the object without joining, while relation() will join a relation on the parent object. If someone has a better name, let me know...

@ghost ghost assigned jschreuder May 3, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant