aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-09 17:47:02 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-09 17:47:09 -0700
commit0061c5e1ef0f7be8946602456a538c263fcafed2 (patch)
tree1626e5490b5d5b8c809344d8175d324ccaa197c9 /activerecord
parentebe9cd8e6196f12cebe5124197f7f029a4a16c9e (diff)
downloadrails-0061c5e1ef0f7be8946602456a538c263fcafed2.tar.gz
rails-0061c5e1ef0f7be8946602456a538c263fcafed2.tar.bz2
rails-0061c5e1ef0f7be8946602456a538c263fcafed2.zip
stop creating a bunch of relation objects when we can slap all the joins on at once
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb6
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb5
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