This project is archived and is in readonly mode.

#211 ✓stale
Troels Petersen

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

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>

Pages