Skip to content
Browse files

make joins generation method look similar

  • Loading branch information...
1 parent 00a426e commit aa5affbff3e89efcefa728cb127c5d8eed993370 @tenderlove tenderlove committed Oct 21, 2013
Showing with 9 additions and 6 deletions.
  1. +9 −6 activerecord/lib/active_record/associations/join_dependency.rb
View
15 activerecord/lib/active_record/associations/join_dependency.rb
@@ -66,7 +66,9 @@ def reflections
end
def join_constraints(outer_joins)
- joins = make_inner_joins join_root
+ joins = join_root.children.flat_map { |child|
+ make_inner_joins join_root, child
+ }
joins.concat outer_joins.flat_map { |oj|
if join_root.match? oj.join_root
@@ -169,11 +171,12 @@ def make_outer_joins(parent, child)
joins.concat child.children.flat_map { |c| make_outer_joins(child, c) }
end
- def make_inner_joins(parent)
- parent.children.flat_map { |child|
- joins = make_constraints(parent, child, child.tables, Arel::InnerJoin)
- joins.concat make_inner_joins(child)
- }
+ def make_inner_joins(parent, child)
+ tables = child.tables
+ join_type = Arel::InnerJoin
+ joins = make_constraints parent, child, tables, join_type
+
+ joins.concat child.children.flat_map { |c| make_inner_joins(child, c) }
end
def table_aliases_for(parent, node)

0 comments on commit aa5affb

Please sign in to comment.
Something went wrong with that request. Please try again.