It's not hard to implement an equivalent for mysql, to reverse where nulls sort
you just use ORDER by -x DESC instead of ORDER BY x ASC. If there's a proper
API for it in AR then it should be easy enough to support both ANSI and Mysql
implementations.
Dunno what the best API is, but I'd suggest something like order("x", :nulls =>
:last). Better than more and more string fudging IMHO.
On 1/08/2013, at 08:40 , Paul Nikitochkin <[email protected]> wrote:
> Hi,
>
> after I investigated https://github.com/rails/rails/issues/11571 issue,
> found that ORDER BY ... NULLS FIRST|LAST expression is supported (documented)
> by ANSI,
> and implemented in PostreSQL (MySQL has another options for this feature and
> does not support for now).
>
> To fix in full that issue reverse_order should generate for "ORDER BY time
> ASC NULLS FIRST" => "ORDER BY time DESC NULLS LAST".
> But adding NULLS FIRST|LAST which are supported only by Postgresql, will add
> more complexity for reverse_sql_order
> (https://github.com/rails/rails/blob/master/activerecord/lib/active_record/relation/query_methods.rb#L978)
>
> Another way is remain current implementation and developer should use custom
> order expression by reorder
>
> topics = Topics.order('time ASC NULLS FIRST')
> reversed_topics = topics.reorder(''time DESC NULLS LAST')
>
> What do you think?
> There is a simple way to do customization, and does Rails need upgraded
> reverse_order to generate valid SQL for custom ORDER BY expressions?
>
> --
> 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 [email protected].
> To post to this group, send email to [email protected].
> Visit this group at http://groups.google.com/group/rubyonrails-core.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/rubyonrails-core.
For more options, visit https://groups.google.com/groups/opt_out.