+1

I don't think of ActiveRecord as an API for manipulating collections of
data but instead an API for composing queries (and mapping data, etc.). I
don't know what's "correct", but it feels intuitive to me that order calls
would be composed consistently with where calls.

-Al

On Mon, Apr 14, 2014 at 9:38 PM, James Coleman <jtc...@gmail.com> wrote:

> We could debate all day what the "correct" way to do it is, but the
> reality is that (and this has been discussed before) that this would be a
> tremendously breaking API change, and therefore shouldn't be done
> regardless.
>
> I will add my 2 cents though on the idea: I don't think that comparing
> relations to arrays is a valid comparison. In the array you're working with
> static, mutable, data, but with a relation you are, by definition, working
> with something that is composable (under relational set theory). So the
> fact that the result is a composition is actually the correct thing for
> this type.
>
>
> On Mon, Apr 14, 2014 at 6:19 PM, Cameron Martin <
> cameronmartin...@gmail.com> wrote:
>
>> When chaining calls to order on an ActiveRecord association, the result
>> is a composition of the two order calls. I believe this breaks the
>> principle of least surprise, since calling sort/order on a collection never
>> behaves like this anywhere else (for example with Array#sort). Any
>> subsequent calls to order should re-order the collection in the way you
>> specify.
>>
>> I can't imagine any situations where you would chain calls to order and
>> want/expect this behaviour, but I can think of many situations where it can
>> lead to unexpected results (for example when using default_scope for
>> ordering).
>>
>> I propose that reorder be renamed to order, and order be renamed to
>> append_order or something similar.
>>
>> Thoughts?
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Ruby on Rails: Core" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to rubyonrails-core+unsubscr...@googlegroups.com.
>> To post to this group, send email to rubyonrails-core@googlegroups.com.
>> Visit this group at http://groups.google.com/group/rubyonrails-core.
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Core" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-core+unsubscr...@googlegroups.com.
> To post to this group, send email to rubyonrails-core@googlegroups.com.
> Visit this group at http://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to rubyonrails-core+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-core@googlegroups.com.
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/d/optout.

Reply via email to