This project is archived and is in readonly mode.
ActiveRecord count with :group and :include fails for sqlite
Reported by Troels Petersen | May 16th, 2008 @ 09:07 PM
The method construct_calculation_sql in calculations.rb constructs invalid SQL when connection.supports_count_distinct? is false, eg for sqlite:
Comment.count(:group => :post, :include => :post)
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such column: post_id:
SELECT COUNT(*) AS count_all, post_id AS post_id FROM (SELECT DISTINCT "comments".id
FROM "comments" LEFT OUTER JOIN "posts" ON "posts".id = "comments".post_id
GROUP BY post_id )
Comments and changes to this ticket
-
josh July 17th, 2008 @ 01:40 AM
- State changed from new to stale
- Tag set to activerecord, sqlite
Closing this ticket as stale. If this is still an issue for you, feel free to reopen this ticket or create a new one with an updated description. Remember those unit tests too ;)
-
Ryan Bigg October 9th, 2010 @ 09:44 PM
- Tag cleared.
- Importance changed from to Low
Automatic cleanup of spam.
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>