1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Revert "Fixes bug in ActiveRecord::QueryMethods, #1697"

This reverts commit 0df27c98d9.

Reverted due to failing test, see #2845.
This commit is contained in:
Jon Leighton 2011-09-04 09:56:55 +01:00
parent 98c3fd87e2
commit ef7e60f008
2 changed files with 4 additions and 7 deletions

View file

@ -305,8 +305,10 @@ module ActiveRecord
when Arel::Nodes::Ordering
o.reverse
when String, Symbol
s = o.to_s.gsub(/\s((desc)|(asc))\s*(,|\Z)/i) { |m| " #{$2 ? 'ASC' : 'DESC'}#{$4}" }
s.match(/\s(de|a)sc\Z/i) ? s : s.concat(" DESC")
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
o
end

View file

@ -934,11 +934,6 @@ class RelationTest < ActiveRecord::TestCase
assert_equal 'zyke', FastCar.order_using_old_style.limit(1).first.name
end
def test_order_with_function_and_last
authors = Author.scoped
assert_equal authors(:bob), authors.order( "id asc, COALESCE( organization_id, owned_essay_id)" ).last
end
def test_order_using_scoping
car1 = CoolCar.order('id DESC').scoping do
CoolCar.find(:first, :order => 'id asc')