From 10b2aa28872b99db42d60c64a25a79daee651839 Mon Sep 17 00:00:00 2001 From: Aaron Patterson Date: Mon, 21 Oct 2013 14:30:50 -0700 Subject: refactor outer join generation --- .../lib/active_record/associations/join_dependency.rb | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 1ffa4a0a6b..7e5a8728ee 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -85,22 +85,17 @@ module ActiveRecord end def join_constraints(outer_joins) - if outer_joins.any? - oj = outer_joins.first + joins = make_joins join_root + joins.concat outer_joins.flat_map { |oj| if join_root.match? oj.join_root - joins = make_joins join_root - joins + walk(join_root, oj.join_root) + walk join_root, oj.join_root else - make_joins(join_root) + outer_joins.flat_map { |join| - join.join_root.children.flat_map { |child| - make_the_joins(join_root, child) - } + oj.join_root.children.flat_map { |child| + make_the_joins(join_root, child) } end - else - make_joins join_root - end + } end class Aliases -- cgit v1.2.3