rails/rails — pull request #14438 by killthekitten (2014-03-20 19:52:09+00:00)
Title: Generate proper SQL when table-prefixed hash key is used in order

`where` method accepts several notation formats, such as `foo: :bar`, `'foo = bar'`, `'foo' => 'bar'` and also `'foo_items.foo' => 'bar'`. Each of them is widely used in RoR apps, and it seems normal to use the same approach in `order`, which in turn supports all except the last one.

Here's what we have now:
```
Topic.order('topics.id' => 'asc').to_sql
# => "SELECT \"topics\".* FROM \"topics\" ORDER BY \"topics\".\"topics.id\" ASC"
```

So this PR is my attempt to implement the desired behavior. Likely this can be done more efficiently.