Skip to content

Commit

Permalink
pass the chain the join_constraints
Browse files Browse the repository at this point in the history
  • Loading branch information
tenderlove committed Oct 15, 2013
1 parent 5c7633c commit 6655663
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Expand Up @@ -159,7 +159,8 @@ def instantiate(result_set, aliases)


def make_joins(node) def make_joins(node)
node.children.flat_map { |child| 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 end


Expand Down
Expand Up @@ -25,7 +25,7 @@ def match?(other)
super && reflection == other.reflection super && reflection == other.reflection
end end


def join_constraints(parent, tables) def join_constraints(parent, tables, chain)
joins = [] joins = []
tables = tables.dup tables = tables.dup


Expand All @@ -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 # The chain starts with the target table, but we want to end with it here (makes
# more sense in this context), so we reverse # more sense in this context), so we reverse
reflection.chain.reverse_each do |reflection| chain.reverse_each do |reflection|
table = tables.shift table = tables.shift
klass = reflection.klass klass = reflection.klass


Expand Down

0 comments on commit 6655663

Please sign in to comment.