ActiveRecord::Relation#order no longer works with arel ordering nodes #1571

jonleighton opened this Issue Jun 8, 2011 · 4 comments


None yet
3 participants

jonleighton commented Jun 8, 2011

Initially reported in #1272:

This has introduced a new problem:

>> Fuu.order(Fuu.arel_table[:name].desc).reverse_order.to_sql
=> "SELECT \"fuus\".* FROM \"fuus\"  ORDER BY #<Arel::Nodes::Ordering:0x0000010319dc88> DESC"


>> Fuu.order(Fuu.arel_table[:name].desc.to_sql).reverse_order.to_sql
=> "SELECT \"fuus\".* FROM \"fuus\"  ORDER BY \"fuus\".\"name\" ASC"

Notice the to_sql call in Fuu.arel_table[:name].desc

jonleighton was assigned Jun 8, 2011


oriolgual commented Jun 8, 2011

Sent pull request #1574 to fix this.


dhh commented Jun 28, 2011

@jonleighton can you apply the pull? Would like to clear out the 3.1 blocker list.


jonleighton commented Jun 28, 2011

@dhh this was already fixed in 08f3f30 so closing this ticket.


oriolgual commented Jun 28, 2011

Well, this isn't really closed.

The problem is that with the latest Arel update, Arel Ordering Nodes got splitted into Descending and Ascending Nodes. Since the tests added 08f3f30 weren't really testing the reverse, no one noticed it.

I'll update the pull request.

@tenderlove tenderlove added a commit to spastorino/rails that referenced this issue Jun 28, 2011

@tenderlove tenderlove Merge pull request #1574 from oriolgual/1571_ar_relation_order_no_lon…

Fix #1571 ActiveRecord::Relation#order no longer works with arel ordering nodes

@jhtwong jhtwong pushed a commit to SAP-Oxygen/rails that referenced this issue Jul 8, 2011

@spastorino spastorino Merge pull request #1904 from oriolgual/1571_fix_for_3_1_stable
Fix #1571 for 3-1-stable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment