1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Merge pull request #21033 from dgynn/preloader_build_scope_tuning

Skip _select! call unless needed for preloader
This commit is contained in:
Arthur Nogueira Neves 2015-10-04 21:07:51 -04:00
commit f854be5e64

View file

@ -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)