diff options
author | Eugene Kenny <elkenny@gmail.com> | 2017-02-26 23:29:08 +0000 |
---|---|---|
committer | Eugene Kenny <elkenny@gmail.com> | 2017-02-27 00:39:12 +0000 |
commit | 6cf4835b743cbce2536d53ae0a4a998f4f0f1e24 (patch) | |
tree | 06ca2aa01fae176323fb1cc6e0a94b8bf7c9b069 /activerecord/test/cases/adapters/mysql2/transaction_test.rb | |
parent | 25c3227255dee0e937e69f58f0cffbf9318948bd (diff) | |
download | rails-6cf4835b743cbce2536d53ae0a4a998f4f0f1e24.tar.gz rails-6cf4835b743cbce2536d53ae0a4a998f4f0f1e24.tar.bz2 rails-6cf4835b743cbce2536d53ae0a4a998f4f0f1e24.zip |
Allow order to be given expressions as hash keys
When `order` is given a hash, the keys are currently assumed to be
attribute names and are quoted as such in the query, which makes it
impossible to pass an expression instead:
Post.order("LENGTH(title)" => :asc).last
# SELECT `posts`.* FROM `posts` ORDER BY `posts`.`LENGTH(title)` DESC LIMIT 1
If the key is an `Arel::Nodes::SqlLiteral`, we now use it directly in
the query. This provides a way to build a relation with a complex order
clause that can still be reversed with `reverse_order` or `last`.
Diffstat (limited to 'activerecord/test/cases/adapters/mysql2/transaction_test.rb')
0 files changed, 0 insertions, 0 deletions