diff options
author | Ben Toews <mastahyeti@gmail.com> | 2017-10-11 13:56:42 -0600 |
---|---|---|
committer | Matthew Draper <matthew@trebex.net> | 2017-11-09 22:42:15 +1030 |
commit | ab03eb9f576312c75e61caaf9705a8ac5175c769 (patch) | |
tree | 24d4bb433238f1eec10a1fb4d76510e382096a58 | |
parent | 798557145c727b2abef2487783f02e57f04197c9 (diff) | |
download | rails-ab03eb9f576312c75e61caaf9705a8ac5175c769.tar.gz rails-ab03eb9f576312c75e61caaf9705a8ac5175c769.tar.bz2 rails-ab03eb9f576312c75e61caaf9705a8ac5175c769.zip |
use << instead of #concat in #reverse_sql_order because we might be working with Arel SQL literator which overrides #concat
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 2 | ||||
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 59a732168c..34723b0b4f 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -1088,7 +1088,7 @@ module ActiveRecord end o.split(",").map! do |s| s.strip! - s.gsub!(/\sasc\Z/i, " DESC") || s.gsub!(/\sdesc\Z/i, " ASC") || s.concat(" DESC") + s.gsub!(/\sasc\Z/i, " DESC") || s.gsub!(/\sdesc\Z/i, " ASC") || (s << " DESC") end else o diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index 6dfb78d913..f3f82e7591 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -238,7 +238,7 @@ class RelationTest < ActiveRecord::TestCase end def test_reverse_order_with_function - topics = Topic.order("length(title)").reverse_order + topics = Topic.order(Arel.sql("length(title)")).reverse_order assert_equal topics(:second).title, topics.first.title end |