This project is archived and is in readonly mode.
build_arel causes counterintuitive behavior with group and order
-
Ernie Miller
- Assigned user set to Jeremy Kemper
Jeremy,
As much as I hate "assigning" tickets since you and I talked about this in IRC and you described the desired behavior, I figure you're the guy to send it to. :)
-
Jeremy Kemper
- State changed from new to open
1) Error: test_find_keeps_multiple_group_values(BasicsTest): ActiveRecord::StatementInvalid: PGError: ERROR: column "developers.id" must appear in the GROUP BY clause or be used in an aggregate function LINE 1: SELECT "developers".* FROM "developers" GROUP BY ... ^ : SELECT "developers".* FROM "developers" GROUP BY developers.name, developers.salary -
Ernie Miller
Argh. CURSE YOU, POSTGRESQL!
Fix forthcoming.
-
Ernie Miller
Here you go!
-
Jeremy Kemper
Thanks! Squashed and removed the extra commit. Looks like a good change but it needs its own test.
-
Repository
- State changed from open to committed
(from [902861a43ae90032063f4a14a3e8b4b9b9c3ca2f]) Fix unintuitive behavior with multiple order and group clauses
[#4545 build_arel causes counterintuitive behavior with group and order state:committed]
Signed-off-by: Jeremy Kemper jeremy@bitsweat.net
http://github.com/rails/rails/commit/902861a43ae90032063f4a14a3e8b4... -
Ernie Miller
Works for me! I only added the last patch in because I inadvertently removed the SqlLiteral in the first one -- see the line:
- arel = arel.order(Arel::SqlLiteral.new(o.to_s)) if o.present?But still, it passes all tests either way, and I think in the case of order clauses the SqlLiteral is redundant if you're already doing a to_s:
articles = Article.arel_table articles.order(Arel::SqlLiteral.new('blah')).orders == articles.order('blah').orders => true -
Jeremy Kemper
Ha - missed that :)
