This project is archived and is in readonly mode.
Giving same association in :include and :join can result in table being joined twice
-
Rishav Rastogi
Hi John,
Can you give us a more concrete example. And if possible a failing test.
-
James Le Cuirot
Sorry for the delay. Here's a failing test case.
-
James Le Cuirot
Actually, as my test case highlights, my original description falls short. You don't even need to specify a second association, merely requiring eager loading for the first association is sufficient to trigger the error.
-
James Le Cuirot
- Importance changed from to
Ignore my last comment. Due to a typo in the test case (author vs authors), I confused myself. My original post was correct.
This has become a bigger problem in my application so I've gone ahead and fixed it. Here is a patch with the fix and an updated test case. I suspect that this will also affect Rails 3 but until I'm ready to migrate my application, I won't have time to look at that. I haven't even looked at the basics of AREL yet.
-
James Le Cuirot
I've realised that this fix does not encompass the count method. There is already a fix for a similar problem here as a result of ticket #302. This does not cover my use case though. I've managed to make the two work together but it involves calling add_joins! twice, which is a little odd. I think my newer fix may be able to replace the older one but I'd need to speak to those responsible.
My question to them is, is it actually necessary to have the separate aliased join? Can we not just avoid the second join in the first place and use the existing one instead? That is what my fix would do. The only caveat is that my code doesn't handle raw join strings, only joins generated through associations.
-
rails
- State changed from new to open
This issue has been automatically marked as stale because it has not been commented on for at least three months.
The resources of the Rails core team are limited, and so we are asking for your help. If you can still reproduce this error on the 3-0-stable branch or on master, please reply with all of the information you have about it and add "[state:open]" to your comment. This will reopen the ticket for review. Likewise, if you feel that this is a very important feature for Rails to include, please reply with your explanation so we can consider it.
Thank you for all your contributions, and we hope you will understand this step to focus our efforts where they are most helpful.
-
rails
- State changed from open to stale
