diff options
author | Dave Gynn <davegynn@gmail.com> | 2015-07-26 10:49:00 -0700 |
---|---|---|
committer | Dave Gynn <davegynn@gmail.com> | 2015-07-26 11:22:01 -0700 |
commit | 1e4ca06c4898a61969a9f3375252d6a5c2087ac0 (patch) | |
tree | df25024270762a2abd2df10ce774e4c8404fd309 /activerecord | |
parent | e90b58106d09af585e85238d7d49cf79f006d4d4 (diff) | |
download | rails-1e4ca06c4898a61969a9f3375252d6a5c2087ac0.tar.gz rails-1e4ca06c4898a61969a9f3375252d6a5c2087ac0.tar.bz2 rails-1e4ca06c4898a61969a9f3375252d6a5c2087ac0.zip |
skip _select! call unless :select values are specified
the default scope will select all fields. removing this
improves performance and reduces String creation.
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/associations/preloader/association.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 1dc8bff193..026de7e525 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -137,7 +137,9 @@ module ActiveRecord scope.where_clause = reflection_scope.where_clause + preload_scope.where_clause scope.references_values = Array(values[:references]) + Array(preload_values[:references]) - scope._select! preload_values[:select] || values[:select] || table[Arel.star] + if preload_values[:select] || values[:select] + scope._select!(preload_values[:select] || values[:select]) + end scope.includes! preload_values[:includes] || values[:includes] if preload_scope.joins_values.any? scope.joins!(preload_scope.joins_values) |