Skip to content
Browse files

make add_order a tad faster

git-svn-id: http://svn-commit.rubyonrails.org/rails/branches/1-2-pre-release@5453 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
1 parent 013004b commit 84668af33067b9d24252f11a5580769d7f6eadf3 @jamis jamis committed Nov 7, 2006
Showing with 8 additions and 4 deletions.
  1. +2 −0 activerecord/CHANGELOG
  2. +6 −4 activerecord/lib/active_record/base.rb
View
2 activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* make add_order a tad faster. #6567 [Stefan Kaes]
+
* Find with :include respects scoped :order. #5850
* Dynamically generate reader methods for serialized attributes. #6362 [Stefan Kaes]
View
10 activerecord/lib/active_record/base.rb
@@ -1096,7 +1096,7 @@ def construct_finder_sql(options)
sql << " GROUP BY #{options[:group]} " if options[:group]
- add_order!(sql, options[:order])
+ add_order!(sql, options[:order], scope)
add_limit!(sql, options, scope)
add_lock!(sql, options, scope)
@@ -1120,12 +1120,14 @@ def safe_to_array(o)
end
end
- def add_order!(sql, order)
+ def add_order!(sql, order, scope = :auto)
+ scope = scope(:find) if :auto == scope
+ scoped_order = scope[:order] if scope
if order
sql << " ORDER BY #{order}"
- sql << ", #{scope(:find, :order)}" if scoped?(:find, :order)
+ sql << ", #{scoped_order}" if scoped_order
else
- sql << " ORDER BY #{scope(:find, :order)}" if scoped?(:find, :order)
+ sql << " ORDER BY #{scoped_order}" if scoped_order
end
end

0 comments on commit 84668af

Please sign in to comment.
Something went wrong with that request. Please try again.