aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2017-09-05 01:35:27 +0900
committerRyuta Kamizono <kamipo@gmail.com>2017-09-05 01:35:27 +0900
commita516fdefb6433993d7fcfda7b834fee1a2309d96 (patch)
treeaaa08c0ab752436afa3541ff88329b8666862faf
parent2b5f5cdd7c1d95716de6a206b6d09ccbb006dc17 (diff)
downloadrails-a516fdefb6433993d7fcfda7b834fee1a2309d96.tar.gz
rails-a516fdefb6433993d7fcfda7b834fee1a2309d96.tar.bz2
rails-a516fdefb6433993d7fcfda7b834fee1a2309d96.zip
Assigning `values` is only necessary when `reflection_scope.where_clause` is not empty
Because `reflection_scope.values` will create extra new hash.
-rw-r--r--activerecord/lib/active_record/associations/preloader/through_association.rb2
1 files changed, 1 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb
index f0a2e88c53..8aac00d910 100644
--- a/activerecord/lib/active_record/associations/preloader/through_association.rb
+++ b/activerecord/lib/active_record/associations/preloader/through_association.rb
@@ -81,12 +81,12 @@ module ActiveRecord
def through_scope
scope = through_reflection.klass.unscoped
- values = reflection_scope.values
if options[:source_type]
scope.where! reflection.foreign_type => options[:source_type]
elsif !reflection_scope.where_clause.empty?
scope.where_clause = reflection_scope.where_clause
+ values = reflection_scope.values
if includes = values[:includes]
scope.includes!(source_reflection.name => includes)