mirror of
https://github.com/github/rails.git
synced 2026-04-26 03:00:59 -04:00
Ordering with extra spaces was raising a SQL exception
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user