aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb1
-rw-r--r--activerecord/test/cases/relations_test.rb4
2 files changed, 5 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index 8bd4732c0c..1654ae1eac 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -311,6 +311,7 @@ module ActiveRecord
o.reverse
when String, Symbol
o.to_s.split(',').collect do |s|
+ s.strip!
s.gsub!(/\sasc\Z/i, ' DESC') || s.gsub!(/\sdesc\Z/i, ' ASC') || s.concat(' DESC')
end
else
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb
index 0aaa0342b1..6363cae371 100644
--- a/activerecord/test/cases/relations_test.rb
+++ b/activerecord/test/cases/relations_test.rb
@@ -961,4 +961,8 @@ class RelationTest < ActiveRecord::TestCase
assert scope.eager_loading?
end
+
+ def test_ordering_with_extra_spaces
+ assert_equal authors(:david), Author.order('organization_id ASC , owned_essay_id DESC').last
+ end
end