Merge pull request #2238 from cesario/order-with-extra-spaces

Ordering with extra spaces was raising a SQL exception
This commit is contained in:
Aaron Patterson
2011-07-24 14:40:15 -07:00
2 changed files with 5 additions and 0 deletions

View File

@@ -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

View File

@@ -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