diff options
author | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-09 17:47:02 -0700 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2013-10-09 17:47:09 -0700 |
commit | 0061c5e1ef0f7be8946602456a538c263fcafed2 (patch) | |
tree | 1626e5490b5d5b8c809344d8175d324ccaa197c9 | |
parent | ebe9cd8e6196f12cebe5124197f7f029a4a16c9e (diff) | |
download | rails-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
-rw-r--r-- | activerecord/lib/active_record/associations/join_dependency.rb | 6 | ||||
-rw-r--r-- | activerecord/lib/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 |