Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

ActiveRecord count with :group and :include fails for sqlite

#211

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 )

Reported by Troels Petersen · May 16th, 2008 @ 09:07 PM

State: stale
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. josh
    josh
    • 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 ;)

    July 17th, 2008 @ 01:40 AM

  2. Ryan Bigg
    Ryan Bigg
    • Tag cleared.
    • Importance changed from to Low

    Automatic cleanup of spam.

    October 9th, 2010 @ 09:44 PM

  3. bingbing