Skip to content

Commit

Permalink
performance improvement based on discussion at http://github.com/rail…
Browse files Browse the repository at this point in the history
…s/rails/commit/fbd1d306b95cc2efb6422e12d26d5818a3a42343

Credit goes to all the participants in the discussion
  • Loading branch information
Neeraj Singh authored and tenderlove committed Sep 28, 2010
1 parent 9b89a43 commit 3f16103
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions activerecord/lib/active_record/relation/query_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,9 @@ def apply_modules(modules)
end

def reverse_sql_order(order_query)
order_query.join(', ').split(',').collect { |s|
if s.match(/\s(asc|ASC)$/)
s.gsub(/\s(asc|ASC)$/, ' DESC')
elsif s.match(/\s(desc|DESC)$/)
s.gsub(/\s(desc|DESC)$/, ' ASC')
else
s + ' DESC'
end
}
order_query.join(', ').split(',').collect do |s|
s.gsub!(/\sasc\Z/i, ' DESC') || s.gsub!(/\sdesc\Z/i, ' ASC') || s.concat(' DESC')
end
end

def array_of_strings?(o)
Expand Down

0 comments on commit 3f16103

Please sign in to comment.