aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/associations/join_dependency.rb
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/lib/active_record/associations/join_dependency.rb')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb8
1 files changed, 7 insertions, 1 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]