mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Ordering with extra spaces was raising a SQL exception
This commit is contained in:
parent
d33eb07543
commit
77bb0b79f2
2 changed files with 5 additions and 0 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue