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

order query is already a string, no need to to_s

This commit is contained in:
Aaron Patterson 2010-08-03 09:16:01 -07:00
parent b8634dddab
commit 41c1aa607d

View file

@ -95,7 +95,7 @@ module ActiveRecord
order_clause = arel.send(:order_clauses).join(', ')
relation = except(:order)
if order_clause.present?
unless order_clauses.blank?
relation.order(reverse_sql_order(order_clause))
else
relation.order("#{@klass.table_name}.#{@klass.primary_key} DESC")
@ -238,7 +238,7 @@ module ActiveRecord
end
def reverse_sql_order(order_query)
order_query.to_s.split(/,/).each { |s|
order_query.split(',').each { |s|
if s.match(/\s(asc|ASC)$/)
s.gsub!(/\s(asc|ASC)$/, ' DESC')
elsif s.match(/\s(desc|DESC)$/)