This project is archived and is in readonly mode.
with_scope and :group option fails for PostgreSQL
Reported by CancelProfileIsBroken | February 28th, 2009 @ 05:10 PM | in 3.x
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.
Comments and changes to this ticket
-
Nicolas Alejandro Santa May 26th, 2009 @ 01:56 AM
Here is an explanation about what is happening.
http://e-haitham.blogspot.com/2008/12/mysql-vs-postgresql-key-diffe...
-
Santiago Pastorino February 2nd, 2011 @ 04:50 PM
- 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.
-
Santiago Pastorino February 2nd, 2011 @ 04:50 PM
- State changed from open to stale
-
Martin Caetano February 20th, 2011 @ 06:25 PM
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): -
Martin Caetano February 20th, 2011 @ 06:29 PM
Here there's more info about how PosgreSQL handles group by
http://stackoverflow.com/questions/4599010/heroku-postgresql-group-...
-
joson April 29th, 2011 @ 09:15 AM
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.
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>