Skip to content

Commit

Permalink
stuff the join dependency object in the "anything goes" hash.
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 10, 2013
1 parent e4ec9ce commit d20ccb7
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 6 deletions.
Expand Up @@ -79,10 +79,10 @@ def reflections
join_root.drop(1).map!(&:reflection)
end

def join_relation(relation)
def outer_joins
nodes = join_root.drop 1
nodes.each { |n| n.join_type = Arel::OuterJoin }
relation.joins(nodes)
nodes
end

def join_constraints
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/relation/finder_methods.rb
Expand Up @@ -267,7 +267,7 @@ def construct_relation_for_association_find(join_dependency)

def apply_join_dependency(relation, join_dependency)
relation = relation.except(:includes, :eager_load, :preload)
relation = join_dependency.join_relation(relation)
relation = relation.joins join_dependency

if using_limitable_reflections?(join_dependency.reflections)
relation
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/relation/merger.rb
Expand Up @@ -94,7 +94,7 @@ def merge_joins
[])
relation.joins! rest

@relation = join_dependency.join_relation(relation)
@relation = relation.joins join_dependency
end
end

Expand Down
6 changes: 4 additions & 2 deletions activerecord/lib/active_record/relation/query_methods.rb
Expand Up @@ -928,7 +928,7 @@ def build_joins(manager, joins)
:string_join
when Hash, Symbol, Array
:association_join
when ActiveRecord::Associations::JoinDependency::JoinAssociation
when ActiveRecord::Associations::JoinDependency
:stashed_join
when Arel::Nodes::Join
:join_node
Expand All @@ -950,7 +950,9 @@ def build_joins(manager, joins)
join_list
)

join_dependency.graft(stashed_association_joins)
stashed_association_joins.each do |dep|
join_dependency.graft dep.outer_joins
end

joins = join_dependency.join_constraints

Expand Down

0 comments on commit d20ccb7

Please sign in to comment.