diff options
Diffstat (limited to 'activerecord/lib')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 8 | ||||
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency/join_association.rb | 2 |
2 files changed, 8 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 6e08f67286..ead2668250 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -80,7 +80,7 @@ module ActiveRecord end def join_constraints - join_root.children.flat_map { |c| c.flat_map(&:join_constraints) } + make_joins join_root end def columns @@ -111,6 +111,12 @@ module ActiveRecord private + def make_joins(node) + node.children.flat_map { |child| + child.join_constraints(node).concat make_joins(child) + } + end + def merge_node(left, right) intersection, missing = right.children.map { |node1| [left.children.find { |node2| node1.match? node2 }, node1] 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 3af613d2d1..0d3834240c 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -38,7 +38,7 @@ module ActiveRecord super && reflection == other.reflection end - def join_constraints + def join_constraints(parent) joins = [] tables = @tables.dup |