aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Patterson <aaron.patterson@gmail.com>2013-10-03 15:13:55 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2013-10-03 15:13:55 -0700
commit8e1b363167c22adcf75e3454dc8bfd34b5801d79 (patch)
tree5bbf3b63096f0bc32c736aca6fa72c294f0bfb67
parent6141d0c4b84a765464852df1dfa06995bba22023 (diff)
downloadrails-8e1b363167c22adcf75e3454dc8bfd34b5801d79.tar.gz
rails-8e1b363167c22adcf75e3454dc8bfd34b5801d79.tar.bz2
rails-8e1b363167c22adcf75e3454dc8bfd34b5801d79.zip
Set the join type on construction
We always set the join type immediately after construction, just make it part of the constructor and we can skip that step
-rw-r--r--activerecord/lib/active_record/associations/join_dependency.rb7
-rw-r--r--activerecord/lib/active_record/associations/join_dependency/join_association.rb4
2 files changed, 5 insertions, 6 deletions
diff --git a/activerecord/lib/active_record/associations/join_dependency.rb b/activerecord/lib/active_record/associations/join_dependency.rb
index 00fe249837..b6bd37d3cb 100644
--- a/activerecord/lib/active_record/associations/join_dependency.rb
+++ b/activerecord/lib/active_record/associations/join_dependency.rb
@@ -137,8 +137,7 @@ module ActiveRecord
raise ConfigurationError, "Association named '#{ associations }' was not found on #{ parent.base_klass.name }; perhaps you misspelled it?"
unless join_association = find_join_association(reflection, parent)
@reflections << reflection
- join_association = build_join_association(reflection, parent)
- join_association.join_type = join_type
+ join_association = build_join_association(reflection, parent, join_type)
@join_parts << join_association
cache_joined_association(join_association)
end
@@ -173,14 +172,14 @@ module ActiveRecord
end
end
- def build_join_association(reflection, parent)
+ def build_join_association(reflection, parent, join_type)
reflection.check_validity!
if reflection.options[:polymorphic]
raise EagerLoadPolymorphicError.new(reflection)
end
- JoinAssociation.new(reflection, self, parent)
+ JoinAssociation.new(reflection, self, parent, join_type)
end
def construct(parent, associations, join_parts, row)
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 3bc7f7ad50..2307564ce7 100644
--- a/activerecord/lib/active_record/associations/join_dependency/join_association.rb
+++ b/activerecord/lib/active_record/associations/join_dependency/join_association.rb
@@ -29,13 +29,13 @@ module ActiveRecord
delegate :options, :through_reflection, :source_reflection, :chain, :to => :reflection
delegate :alias_tracker, :to => :join_dependency
- def initialize(reflection, join_dependency, parent)
+ def initialize(reflection, join_dependency, parent, join_type)
super(reflection.klass)
@reflection = reflection
@join_dependency = join_dependency
@parent = parent
- @join_type = Arel::InnerJoin
+ @join_type = join_type
@aliased_prefix = "t#{ join_dependency.join_parts.size }"
@tables = construct_tables.reverse
end