On Dec 28, 2011, at 5:55 AM, Jon Leighton wrote:
> 
>> As a side-effect of that
>> implementation, this code:
>> 
>> SomeModel.order('foo ASC').reorder('bar DESC').order('baz ASC')
>> 
>> does not (as might be expected) sort the returned record by baz - the
>> reorder overrides all previous *and* subsequent orders.
> 
> I think this is a bug.

Here's a pull request to correct this behavior:

https://github.com/rails/rails/pull/4282

This also solves the original problem in a slightly different way - a 
relation's order_values attribute is now always the ordering the final relation 
will use.

--Matt Jones

PS:
I also noticed a tangentially related issue - reverse_order has a similar sort 
of issue with late-application; for instance, this:

SomeModel.order('foo ASC').reverse_order.order('bar ASC')

will wind up with an order of 'foo DESC, bar DESC' since the reverse isn't 
handled until build_arel is called...

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-core?hl=en.

Reply via email to