Permalink
Browse files

performance improvement based on discussion at http://github.com/rail…

…s/rails/commit/fbd1d306b95cc2efb6422e12d26d5818a3a42343

Credit goes to all the participants in the discussion
  • Loading branch information...
1 parent 9b89a43 commit 3f16103daf330a067454dd2ae324d8d238ac5ba3 Neeraj Singh committed with tenderlove Sep 28, 2010
Showing with 3 additions and 9 deletions.
  1. +3 −9 activerecord/lib/active_record/relation/query_methods.rb
@@ -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)

0 comments on commit 3f16103

Please sign in to comment.