aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-08 11:26:29 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-08 11:26:29 -0700
commit84499eb4bd2e5fe686199c122194b72040411d04 (patch)
treea39c5739cb4b08314c73326892d5a53df7c1dac4 /activerecord/lib/active_record/associations
parentbf8628df0a8422d54350b3e66f5f56b43576f350 (diff)
downloadrails-84499eb4bd2e5fe686199c122194b72040411d04.tar.gz
rails-84499eb4bd2e5fe686199c122194b72040411d04.tar.bz2
rails-84499eb4bd2e5fe686199c122194b72040411d04.zip
decouple JoinAssociation from JoinDependency
Diffstat (limited to 'activerecord/lib/active_record/associations')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb2
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb13
2 files changed, 5 insertions, 10 deletions
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