diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 00fe2498374cf1fa282097181ba9ff33a20952e2..b6bd37d3cba48ff86894f1b1010ed65469f3200f 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -137,8 +137,7 @@ def build(associations, parent = join_parts.last, join_type = Arel::InnerJoin) raise ConfigurationError, "Association named '#{ associations }' was not found on #{ parent.base_klass.name }; perhaps you misspelled it?" unless join_association = find_join_association(reflection, parent) @reflections << reflection - join_association = build_join_association(reflection, parent) - join_association.join_type = join_type + join_association = build_join_association(reflection, parent, join_type) @join_parts << join_association cache_joined_association(join_association) end @@ -173,14 +172,14 @@ def remove_uniq_by_reflection(reflection, records) end end - def build_join_association(reflection, parent) + def build_join_association(reflection, parent, join_type) reflection.check_validity! if reflection.options[:polymorphic] raise EagerLoadPolymorphicError.new(reflection) end - JoinAssociation.new(reflection, self, parent) + JoinAssociation.new(reflection, self, parent, join_type) end def construct(parent, associations, join_parts, row) 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 3bc7f7ad5022a45f9fc0afcb88f795f83a0e6661..2307564ce7c269000147313164216c27ea8c2ffb 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -29,13 +29,13 @@ class JoinAssociation < JoinPart # :nodoc: delegate :options, :through_reflection, :source_reflection, :chain, :to => :reflection delegate :alias_tracker, :to => :join_dependency - def initialize(reflection, join_dependency, parent) + def initialize(reflection, join_dependency, parent, join_type) super(reflection.klass) @reflection = reflection @join_dependency = join_dependency @parent = parent - @join_type = Arel::InnerJoin + @join_type = join_type @aliased_prefix = "t#{ join_dependency.join_parts.size }" @tables = construct_tables.reverse end