Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

remove apply_finder_options call from AssociationScope

  • Loading branch information...
commit be89e9a35162b3015e2aee53300fdf04752652ce 1 parent 8d5be98
@jonleighton jonleighton authored
View
15 activerecord/lib/active_record/associations/association_scope.rb
@@ -15,19 +15,20 @@ def initialize(association)
def scope
scope = klass.unscoped
- scope = scope.extending(*Array(options[:extend]))
+
+ scope.extending!(*Array(options[:extend]))
# It's okay to just apply all these like this. The options will only be present if the
# association supports that option; this is enforced by the association builder.
- scope = scope.apply_finder_options(options.slice(
- :readonly, :include, :references, :order, :limit, :joins, :group, :having, :offset, :select))
+ scope.merge!(options.slice(
+ :readonly, :references, :order, :limit, :joins, :group, :having, :offset, :select, :uniq))
- if options[:through] && !options[:include]
- scope = scope.includes(source_options[:include])
+ if options[:include]
+ scope.includes! options[:include]
+ elsif options[:through]
+ scope.includes! source_options[:include]
end
- scope = scope.uniq if options[:uniq]
-
add_constraints(scope)
end
View
2  activerecord/lib/active_record/relation/merger.rb
@@ -69,7 +69,7 @@ def merge_multi_values
relation.reorder! values[:order]
elsif values[:order]
# merge in order_values from r
- relation.order_values += values[:order]
+ relation.order! values[:order]
end
relation.extend(*values[:extending]) unless values[:extending].blank?
View
2  activerecord/lib/active_record/relation/query_methods.rb
@@ -356,7 +356,7 @@ def extending!(*modules, &block)
modules << Module.new(&block) if block_given?
self.extending_values = modules.flatten
- extend(*extending_values)
+ extend(*extending_values) if extending_values.any?
self
end
View
5 activerecord/test/cases/relation_test.rb
@@ -176,6 +176,11 @@ def relation
assert relation.is_a?(mod)
end
+ test 'extending! with empty args' do
+ relation.extending!
+ assert_equal [], relation.extending_values
+ end
+
(Relation::SINGLE_VALUE_METHODS - [:lock, :reordering, :reverse_order, :create_with]).each do |method|
test "##{method}!" do
assert relation.public_send("#{method}!", :foo).equal?(relation)
Please sign in to comment.
Something went wrong with that request. Please try again.