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

Closed
jonleighton opened this Issue Jun 8, 2011 · 4 comments

Comments

Projects
None yet
3 participants
Member

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"

Versus:

>> 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

Contributor

oriolgual commented Jun 8, 2011

Sent pull request #1574 to fix this.

Owner

dhh commented Jun 28, 2011

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

Member

jonleighton commented Jun 28, 2011

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

Contributor

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…
…ger_works_with_arel_nodes

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

@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
e7ac539
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment