diff options
author | Arthur Nogueira Neves <github@arthurnn.com> | 2015-10-04 21:07:51 -0400 |
---|---|---|
committer | Arthur Nogueira Neves <github@arthurnn.com> | 2015-10-04 21:07:51 -0400 |
commit | f854be5e64737a7432570e9ce9d3edc38819e50a (patch) | |
tree | e3afa254b0ba0c7e781a5373376b3a8466c33fb7 /activerecord/lib | |
parent | dcdf231b38f30a00e5e769e33cf8e43745dbe489 (diff) | |
parent | 1e4ca06c4898a61969a9f3375252d6a5c2087ac0 (diff) | |
download | rails-f854be5e64737a7432570e9ce9d3edc38819e50a.tar.gz rails-f854be5e64737a7432570e9ce9d3edc38819e50a.tar.bz2 rails-f854be5e64737a7432570e9ce9d3edc38819e50a.zip |
Merge pull request #21033 from dgynn/preloader_build_scope_tuning
Skip _select! call unless needed for preloader
Diffstat (limited to 'activerecord/lib')
-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 92792a7a15..7a5a8f8ae6 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) |