diff options
Diffstat (limited to 'activerecord/lib/active_record/associations/join_dependency.rb')
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 17 |
1 files 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 |