aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorRafael França <rafaelmfranca@gmail.com>2017-03-17 13:22:20 -0400
committerGitHub <noreply@github.com>2017-03-17 13:22:20 -0400
commitbac40b9cc8bae5a88743dba01bdee24ef8a2d579 (patch)
tree1e3d1103798ee613bc877a06b8076fd616c20fee /activerecord/lib/active_record/relation
parent6f7e7aadfdc76990176a5f3c4d0024aa665ef173 (diff)
parent6cf4835b743cbce2536d53ae0a4a998f4f0f1e24 (diff)
downloadrails-bac40b9cc8bae5a88743dba01bdee24ef8a2d579.tar.gz
rails-bac40b9cc8bae5a88743dba01bdee24ef8a2d579.tar.bz2
rails-bac40b9cc8bae5a88743dba01bdee24ef8a2d579.zip
Merge pull request #28191 from eugeneius/string_assoc_order
Allow order to be given expressions as hash keys
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb7
1 files changed, 6 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 4ee413c805..1178dec706 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -1130,7 +1130,12 @@ module ActiveRecord
arel_attribute(arg).asc
when Hash
arg.map { |field, dir|
- arel_attribute(field).send(dir.downcase)
+ case field
+ when Arel::Nodes::SqlLiteral
+ field.send(dir.downcase)
+ else
+ arel_attribute(field).send(dir.downcase)
+ end
}
else
arg