aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2006-04-01 23:15:35 +0000
committerRick Olson <technoweenie@gmail.com>2006-04-01 23:15:35 +0000
commita3f20132dbdedefd1d0ac6c419df7d0af0dff638 (patch)
treea6bf325c0b3b0a739e0c70edf684db374258c6f5
parenteefc22fa95e485231f8743f49a321ac285db9777 (diff)
downloadrails-a3f20132dbdedefd1d0ac6c419df7d0af0dff638.tar.gz
rails-a3f20132dbdedefd1d0ac6c419df7d0af0dff638.tar.bz2
rails-a3f20132dbdedefd1d0ac6c419df7d0af0dff638.zip
Private ActiveRecord methods add_limit, add_joins, and add_conditions take an OPTIONAL third argument 'scope' (closes #4456) [Rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4129 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb13
2 files changed, 11 insertions, 4 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index b14e029df5..f55d8d6e0f 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* 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]
* Fixed that records returned from has_and_belongs_to_many associations with additional attributes should be marked as read only (fixes #4512) [DHH]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 28ae612dad..0828df8d68 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1036,21 +1036,26 @@ module ActiveRecord #:nodoc:
end
end
- def add_limit!(sql, options, scope)
- if scope
+ # The optional scope argument is for the current :find scope.
+ def add_limit!(sql, options, scope = nil)
+ if scope ||= scope(:find)
options[:limit] ||= scope[:limit]
options[:offset] ||= scope[:offset]
end
connection.add_limit_offset!(sql, options)
end
- def add_joins!(sql, options, scope)
+ # The optional scope argument is for the current :find scope.
+ def add_joins!(sql, options, scope = nil)
+ scope ||= scope(:find)
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.
- def add_conditions!(sql, conditions, scope)
+ # The optional scope argument is for the current :find scope.
+ def add_conditions!(sql, conditions, scope = nil)
+ scope ||= scope(:find)
segments = []
segments << sanitize_sql(scope[:conditions]) if scope && scope[:conditions]
segments << sanitize_sql(conditions) unless conditions.nil?