rails/rails — pull request #11690 by pftg (2013-07-31 20:01:45+00:00)
Title: Reverse order with order direction in the middle

Order part of query with custom statements like `nulls first` or
`nulls last` at the end which arrange `null` values to top or bottom,
is broken for reverse order sql generation by adding `DESC` at the end,
because of skipping `asc|desc` before `nulls first|last` expression.

Refactored `reverse_sql_order` to take this in account:
that there is `nulls` statement after order direction
which are added by SQL:2003 extension T611, "Elementary OLAP operations" (https://en.wikipedia.org/wiki/Order_by).

Closes #11571