Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

decouple the `join_constraints` method from the parent pointer

  • Loading branch information...
commit 2550acc779877720710cfaca120196109da70c04 1 parent cc362fe
@tenderlove tenderlove authored
View
8 activerecord/lib/active_record/associations/join_dependency.rb
@@ -80,7 +80,7 @@ def merge_outer_joins!(other)
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 @@ def instantiate(result_set)
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]
View
2  activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -38,7 +38,7 @@ def match?(other)
super && reflection == other.reflection
end
- def join_constraints
+ def join_constraints(parent)
joins = []
tables = @tables.dup
Please sign in to comment.
Something went wrong with that request. Please try again.