Skip to content

Commit

Permalink
Use array of orders instead of string concatenation
Browse files Browse the repository at this point in the history
  • Loading branch information
miloops committed Jun 10, 2009
1 parent 0587462 commit af9f9dd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -1750,17 +1750,15 @@ def construct_group(group, having, scope = :auto)
end end


def construct_order(order, scope = :auto) def construct_order(order, scope = :auto)
sql = '' orders = []
scoped_order = scope[:order] if scope scoped_order = scope[:order] if scope
if order if order
sql << order.to_s orders << order
if scoped_order && scoped_order != order orders << scoped_order if scoped_order && scoped_order != order
sql << ", #{scoped_order}"
end
else else
sql << scoped_order.to_s if scoped_order orders << scoped_order if scoped_order
end end
sql orders
end end


def construct_limit(options, scope = :auto) def construct_limit(options, scope = :auto)
Expand Down

0 comments on commit af9f9dd

Please sign in to comment.