aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-04-03 16:09:47 +0000
committerRick Olson <technoweenie@gmail.com>2006-04-03 16:09:47 +0000
commitdb7fadd7300e07bac343ff7b9d2056fe8b37475f (patch)
treeb6a5e0872e14bad827c25073b534fb72f3831434
parent6c2d167cd96485cba338059f902411305faa26ad (diff)
downloadrails-db7fadd7300e07bac343ff7b9d2056fe8b37475f.tar.gz
rails-db7fadd7300e07bac343ff7b9d2056fe8b37475f.tar.bz2
rails-db7fadd7300e07bac343ff7b9d2056fe8b37475f.zip
Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4141 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb15
2 files changed, 10 insertions, 7 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index f55d8d6e0f..ebeb0cf969 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Changed those private ActiveRecord methods to take optional third argument :auto instead of nil for performance optimizations. (closes #4456) [Stefan]
+
* Private ActiveRecord methods add_limit!, add_joins!, and add_conditions! take an OPTIONAL third argument 'scope' (closes #4456) [Rick]
* DEPRECATED: Using additional attributes on has_and_belongs_to_many associations. Instead upgrade your association to be a real join model [DHH]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 72191c60c4..680d8db357 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -871,7 +871,7 @@ module ActiveRecord #:nodoc:
begin
yield
- ensure
+ ensure
self.scoped_methods.pop
end
end
@@ -1037,8 +1037,9 @@ module ActiveRecord #:nodoc:
end
# The optional scope argument is for the current :find scope.
- def add_limit!(sql, options, scope = nil)
- if scope ||= scope(:find)
+ def add_limit!(sql, options, scope = :auto)
+ scope = scope(:find) if :auto == scope
+ if scope
options[:limit] ||= scope[:limit]
options[:offset] ||= scope[:offset]
end
@@ -1046,16 +1047,16 @@ module ActiveRecord #:nodoc:
end
# The optional scope argument is for the current :find scope.
- def add_joins!(sql, options, scope = nil)
- scope ||= scope(:find)
+ def add_joins!(sql, options, scope = :auto)
+ scope = scope(:find) if :auto == scope
join = (scope && scope[:joins]) || options[:joins]
sql << " #{join} " if join
end
# Adds a sanitized version of +conditions+ to the +sql+ string. Note that the passed-in +sql+ string is changed.
# The optional scope argument is for the current :find scope.
- def add_conditions!(sql, conditions, scope = nil)
- scope ||= scope(:find)
+ def add_conditions!(sql, conditions, scope = :auto)
+ scope = scope(:find) if :auto == scope
segments = []
segments << sanitize_sql(scope[:conditions]) if scope && scope[:conditions]
segments << sanitize_sql(conditions) unless conditions.nil?