From 0061c5e1ef0f7be8946602456a538c263fcafed2 Mon Sep 17 00:00:00 2001 From: Aaron Patterson <aaron.patterson@gmail.com> Date: Wed, 9 Oct 2013 17:47:02 -0700 Subject: stop creating a bunch of relation objects when we can slap all the joins on at once --- activerecord/lib/active_record/associations/join_dependency.rb | 6 +++--- .../active_record/associations/join_dependency/join_association.rb | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb index 2fdb1970e1..e2d4cf4378 100644 --- a/activerecord/lib/active_record/associations/join_dependency.rb +++ b/activerecord/lib/active_record/associations/join_dependency.rb @@ -80,9 +80,9 @@ module ActiveRecord end def join_relation(relation) - join_root.inject(relation) do |rel,association| - association.join_relation(rel) - end + nodes = join_root.drop 1 + nodes.each { |n| n.join_type = Arel::OuterJoin } + relation.joins(nodes) end def join_constraints diff --git a/activerecord/lib/active_record/associations/join_dependency/join_association.rb b/activerecord/lib/active_record/associations/join_dependency/join_association.rb index fe915c7730..3af613d2d1 100644 --- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb +++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb @@ -125,11 +125,6 @@ module ActiveRecord constraint end - def join_relation(joining_relation) - self.join_type = Arel::OuterJoin - joining_relation.joins(self) - end - def table tables.last end -- cgit v1.2.3