This project is archived and is in readonly mode.
Only join includes referenced in conditions for count
Reported by John Devine | December 8th, 2008 @ 05:38 AM | in 3.x
When issuing ActiveRecord.count queries, include options are now turned into joins indiscriminately. This patch copies the strategy from associations.rb construct_finder_sql_for_association_limiting by only adding include joins to the query if they are referenced by the condition string.
Some may say, well just don't put the includes in the options but that's a lot of things to think about.
This saves me from my stupidity since I use a hack of the "paginating_find" plugin, which does a count of a limited query before firing the actual query.
No new tests included in the patch. All the (previously passing) tests still pass.
Comments and changes to this ticket
-
Pratik March 7th, 2009 @ 03:44 PM
- Assigned user set to Pratik
- Tag changed from activerecord, calculations to activerecord, calculations, patch
- State changed from new to incomplete
- Title changed from [PATCH] only join includes referenced in conditions for count to Only join includes referenced in conditions for count
Patch should still have a test displaying the behaviour that's broken at the moment.
Thanks !
-
John Devine March 19th, 2009 @ 10:37 PM
I'll see if I can come up with some tests this weekend -- but I've never done a test for a specific SQL statement. Since nothing's actually broken (in terms of results) now, I don't know what the test would look like. Any suggestions welcome.
-
Santiago Pastorino February 2nd, 2011 @ 05:04 PM
- State changed from incomplete to open
- Importance changed from to
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.
-
Santiago Pastorino February 2nd, 2011 @ 05:04 PM
- State changed from open to stale
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>