Permalink
Browse files

pass the chain the join_constraints

  • Loading branch information...
tenderlove committed Oct 15, 2013
1 parent 5c7633c commit 66556631f5b98990d55194f427533a4b992b3350
@@ -159,7 +159,8 @@ def instantiate(result_set, aliases)
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
@@ -25,7 +25,7 @@ def match?(other)
super && reflection == other.reflection
end
- def join_constraints(parent, tables)
+ def join_constraints(parent, tables, chain)
joins = []
tables = tables.dup
@@ -36,7 +36,7 @@ def join_constraints(parent, tables)
# 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

0 comments on commit 6655663

Please sign in to comment.