From 84499eb4bd2e5fe686199c122194b72040411d04 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Tue, 8 Oct 2013 11:26:29 -0700 Subject: decouple JoinAssociation from JoinDependency --- .../lib/active_record/associations/join_dependency.rb | 2 +- .../associations/join_dependency/join_association.rb | 13 ++++--------- 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'activerecord/lib/active_record/associations') diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index b3bc75e08b..89812a3826 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -176,7 +176,7 @@ module ActiveRecord raise EagerLoadPolymorphicError.new(reflection) end - JoinAssociation.new(reflection, self, parent, join_type) + JoinAssociation.new(reflection, join_parts.length, parent, join_type, alias_tracker) end def construct(parent, associations, join_parts, row, rs) diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index 2307564ce7..ef8f5f1eb2 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -9,11 +9,6 @@ module ActiveRecord # The reflection of the association represented attr_reader :reflection - # The JoinDependency object which this JoinAssociation exists within. This is mainly - # relevant for generating aliases which do not conflict with other joins which are - # part of the query. - attr_reader :join_dependency - # A JoinBase instance representing the active record we are joining onto. # (So in Author.has_many :posts, the Author would be that base record.) attr_reader :parent @@ -25,18 +20,18 @@ module ActiveRecord attr_reader :aliased_prefix attr_reader :tables + attr_reader :alias_tracker delegate :options, :through_reflection, :source_reflection, :chain, :to => :reflection - delegate :alias_tracker, :to => :join_dependency - def initialize(reflection, join_dependency, parent, join_type) + def initialize(reflection, index, parent, join_type, alias_tracker) super(reflection.klass) @reflection = reflection - @join_dependency = join_dependency + @alias_tracker = alias_tracker @parent = parent @join_type = join_type - @aliased_prefix = "t#{ join_dependency.join_parts.size }" + @aliased_prefix = "t#{ index }" @tables = construct_tables.reverse end -- cgit v1.2.3