提交 8e1b3631 编写于 作者: A Aaron Patterson

Set the join type on construction

We always set the join type immediately after construction, just make it
part of the constructor and we can skip that step
上级 6141d0c4
......@@ -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)
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册