Permalink
Browse files

Pull the excepts into apply_join_dependency, for the sake of DRY.

  • Loading branch information...
1 parent 1dcb1cc commit 88219cc88aadf75fe57a1ecacbe92a7acef64145 @Empact Empact committed May 10, 2013
Showing with 4 additions and 3 deletions.
  1. +4 −3 activerecord/lib/active_record/relation/finder_methods.rb
View
7 activerecord/lib/active_record/relation/finder_methods.rb
@@ -217,16 +217,17 @@ def construct_join_dependency_for_association_find
def construct_relation_for_association_calculations
including = (eager_load_values + includes_values).uniq
join_dependency = ActiveRecord::Associations::JoinDependency.new(@klass, including, arel.froms.first)
- relation = except(:includes, :eager_load, :preload)
- apply_join_dependency(relation, join_dependency)
+ apply_join_dependency(self, join_dependency)
end
def construct_relation_for_association_find(join_dependency)
- relation = except(:includes, :eager_load, :preload, :select).select(join_dependency.columns)
+ relation = except(:select).select(join_dependency.columns)
apply_join_dependency(relation, join_dependency)
end
def apply_join_dependency(relation, join_dependency)
+ relation = relation.except(:includes, :eager_load, :preload)
+
join_dependency.join_associations.each do |association|
relation = association.join_relation(relation)
end

0 comments on commit 88219cc

Please sign in to comment.