aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-10 16:04:32 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-11 11:07:15 -0700
commit2550acc779877720710cfaca120196109da70c04 (patch)
tree5ae505fc75303e733f10ee1b8d421020e0831f9a /activerecord
parentcc362fe17b9a3e4be34a6a5a9f97f9c271bd7513 (diff)
downloadrails-2550acc779877720710cfaca120196109da70c04.tar.gz
rails-2550acc779877720710cfaca120196109da70c04.tar.bz2
rails-2550acc779877720710cfaca120196109da70c04.zip
decouple the `join_constraints` method from the parent pointer
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb8
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb2
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