This project is archived and is in readonly mode.

#4545 ✓committed
Ernie Miller

build_arel causes counterintuitive behavior with group and order

Reported by Ernie Miller | May 6th, 2010 @ 09:28 PM

Current version of Arel does not handle multiple calls to order and group as it would appear build_arel expects it to.

ruby-1.8.7-p249 > Article.order(:id, :created_by).to_sql
=> "SELECT     \"articles\".* FROM       \"articles\" ORDER BY  created_by, id"

ruby-1.8.7-p249 > Article.group(:id, :created_by).to_sql
=> "SELECT     \"articles\".* FROM       \"articles\" GROUP BY  created_by"

With order, the last added order is given precedence. With group_by, only one call is allowed. This patch calls both a single time with the entire usable list of order/group parameters and results in the expected behavior.

Thanks!

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>

People watching this ticket

Referenced by

Pages