diff options
author | Jamis Buck <jamis@37signals.com> | 2006-11-07 19:06:35 +0000 |
---|---|---|
committer | Jamis Buck <jamis@37signals.com> | 2006-11-07 19:06:35 +0000 |
commit | 57a3e44052676db61a11f4f0052a8d837cddecce (patch) | |
tree | 7dcbe7166d4d41f3a6afd97fee0256c95ae56c26 /activerecord | |
parent | a3dba1ed7cabc53d474c37eba973d617445b389e (diff) | |
download | rails-57a3e44052676db61a11f4f0052a8d837cddecce.tar.gz rails-57a3e44052676db61a11f4f0052a8d837cddecce.tar.bz2 rails-57a3e44052676db61a11f4f0052a8d837cddecce.zip |
make add_order a tad faster (Closes #6567)
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5452 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/CHANGELOG | 2 | ||||
-rwxr-xr-x | activerecord/lib/active_record/base.rb | 10 |
2 files changed, 8 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG index 6c0dce4309..4726464980 100644 --- a/activerecord/CHANGELOG +++ b/activerecord/CHANGELOG @@ -1,5 +1,7 @@ *SVN* +* make add_order a tad faster. #6567 [Stefan Kaes] + * Find with :include respects scoped :order. #5850 * Support nil and Array in :conditions => { attr => value } hashes. #6548 [Assaf, Jeremy Kemper] diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb index c09cef1118..c35453f326 100755 --- a/activerecord/lib/active_record/base.rb +++ b/activerecord/lib/active_record/base.rb @@ -1096,7 +1096,7 @@ module ActiveRecord #:nodoc: 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 @@ module ActiveRecord #:nodoc: 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 |