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.

with_scope and :group option fails for PostgreSQL

#2102

We fail on this using PostgresQL, due to rules on what the SELECT clause contains. Passes in MySQL/SQLite3.

def test_scoped_find_with_group developers = Developer.with_scope(:find => { :group => 'salary' }) do

Developer.find(:all)

end assert_equal 4, developers.size end

=> ActiveRecord::StatementInvalid: PGError: ERROR: column "developers.id" must appear in the GROUP BY clause or be used in an aggregate function : SELECT * FROM "developers" GROUP BY salary

Diff with the failing test attached. No patch yet.

Reported by CancelProfileIsBroken · February 28th, 2009 @ 05:10 PM

State: stale
Milestone: 3.x
Assigned to: Pratik Pratik
Importance: none

Activity

  1. Nicolas Alejandro Santa
  2. Jeremy Kemper
    Jeremy Kemper
    • Milestone changed from 2.x to 3.x

    May 4th, 2010 @ 06:48 PM

  3. Santiago Pastorino
    Santiago Pastorino
    • State changed from new to open
    • Tag changed from 2.3, activerecord, bug to 23, activerecord, bug

    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.

    February 2nd, 2011 @ 04:50 PM

  4. Santiago Pastorino
    Santiago Pastorino
    • State changed from open to stale

    February 2nd, 2011 @ 04:50 PM

  5. Martin Caetano
    Martin Caetano

    I'm having the same problem when deploying to Heroku.

    Query is:

    @conversations = Conversation.all(:conditions => ["user_id = ? or friend_id = ?", @conversation.user_id, @conversation.user_id], :group => "friend_id", :order => "created_at desc")

    And the error I get from console

    ActiveRecord::StatementInvalid (PGError: ERROR: column "conversations.id" must appear in the GROUP BY clause or be used in an aggregate function
    : SELECT "conversations".* FROM "conversations" WHERE (user_id = 1 or friend_id = 1) GROUP BY friend_id ORDER BY created_at desc):

    February 20th, 2011 @ 06:25 PM

  6. Martin Caetano
  7. bingbing
  8. joson
    joson

    A Replica Breitling is a timepiece of high quality and functionality and you will have all the class, prestige and luxury of a wealthy, successful individual. By choosing from our selection of luxury Replica Watches , you can improve your self-esteem and feel confident to enter new circles of business associates and friends. These Rolex Replicas will surely enhance your style and only you will know the watch you wear did not cost you $1,000's of dollars.

    April 29th, 2011 @ 09:15 AM