aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-15 15:11:52 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-15 15:11:52 -0700
commit66556631f5b98990d55194f427533a4b992b3350 (patch)
treeee8afcdcaf37f188ff00624bb533d6a990d7ee53 /activerecord/lib
parent5c7633cd30a80e9cf747ff39798aea8c03f70420 (diff)
downloadrails-66556631f5b98990d55194f427533a4b992b3350.tar.gz
rails-66556631f5b98990d55194f427533a4b992b3350.tar.bz2
rails-66556631f5b98990d55194f427533a4b992b3350.zip
pass the chain the join_constraints
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb3
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb4
2 files changed, 4 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb
index 7dffc3e3e5..68bdd41101 100644
--- a/activerecord/lib/active_record/associations/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/join_dependency.rb
@@ -159,7 +159,8 @@ module ActiveRecord
def make_joins(node)
node.children.flat_map { |child|
- child.join_constraints(node, child.tables).concat make_joins(child)
+ child.join_constraints(node, child.tables, child.reflection.chain)
+ .concat make_joins(child)
}
end
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 a6a7b447cc..b47ee17aff 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -25,7 +25,7 @@ module ActiveRecord
super && reflection == other.reflection
end
- def join_constraints(parent, tables)
+ def join_constraints(parent, tables, chain)
joins = []
tables = tables.dup
@@ -36,7 +36,7 @@ module ActiveRecord
# The chain starts with the target table, but we want to end with it here (makes
# more sense in this context), so we reverse
- reflection.chain.reverse_each do |reflection|
+ chain.reverse_each do |reflection|
table = tables.shift
klass = reflection.klass