Skip to content

Commit

Permalink
Changed those private ActiveRecord methods to take optional third arg…
Browse files Browse the repository at this point in the history
…ument :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
  • Loading branch information
technoweenie committed Apr 3, 2006
1 parent 6c2d167 commit db7fadd
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 2 additions & 0 deletions 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]
Expand Down
15 changes: 8 additions & 7 deletions activerecord/lib/active_record/base.rb
Expand Up @@ -871,7 +871,7 @@ def with_scope(method_scoping = {}, action = :merge, &block)

begin
yield
ensure
ensure
self.scoped_methods.pop
end
end
Expand Down Expand Up @@ -1037,25 +1037,26 @@ def safe_to_array(o)
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
connection.add_limit_offset!(sql, options)
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?
Expand Down

0 comments on commit db7fadd

Please sign in to comment.