diff options
author | Sean Griffin <sean@thoughtbot.com> | 2015-01-25 16:44:04 -0700 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2015-01-25 16:46:54 -0700 |
commit | 320600c773a16418fe37eccea2eb1082f58062f7 (patch) | |
tree | d86a82ab4a16a178c16d747257d9dac46a3c0908 /activerecord/lib/active_record/associations | |
parent | 87726b93d4fd447671d0b20ae2ec37a9eb4f2fd4 (diff) | |
download | rails-320600c773a16418fe37eccea2eb1082f58062f7.tar.gz rails-320600c773a16418fe37eccea2eb1082f58062f7.tar.bz2 rails-320600c773a16418fe37eccea2eb1082f58062f7.zip |
Remove all references to `where_values` in association code
Diffstat (limited to 'activerecord/lib/active_record/associations')
4 files changed, 7 insertions, 12 deletions
diff --git a/activerecord/lib/active_record/associations/association_scope.rb b/activerecord/lib/active_record/associations/association_scope.rb index 3d71e73b3c..a2550fa382 100644 --- a/activerecord/lib/active_record/associations/association_scope.rb +++ b/activerecord/lib/active_record/associations/association_scope.rb @@ -167,8 +167,7 @@ module ActiveRecord scope.includes! item.includes_values end - scope.where_values += item.where_values - scope.bind_values += item.bind_values + scope.where_clause += item.where_clause scope.order_values |= item.order_values end diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index 0a5ef601a2..c3e49007ea 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -89,7 +89,7 @@ module ActiveRecord # { author: :avatar } # [ :books, { author: :avatar } ] - NULL_RELATION = Struct.new(:values, :bind_values, :where_values).new({}, [], []) + NULL_RELATION = Struct.new(:values, :where_clause).new({}, Relation::WhereClause.empty) def preload(records, associations, preload_scope = nil) records = Array.wrap(records).compact.uniq diff --git a/activerecord/lib/active_record/associations/preloader/association.rb b/activerecord/lib/active_record/associations/preloader/association.rb index 8f001770f7..23848f5e54 100644 --- a/activerecord/lib/active_record/associations/preloader/association.rb +++ b/activerecord/lib/active_record/associations/preloader/association.rb @@ -131,16 +131,13 @@ module ActiveRecord def build_scope scope = klass.unscoped - values = reflection_scope.values - reflection_binds = reflection_scope.bind_values + values = reflection_scope.values preload_values = preload_scope.values - preload_binds = preload_scope.bind_values - scope.where_values = reflection_scope.where_values + preload_scope.where_values + scope.where_clause = reflection_scope.where_clause + preload_scope.where_clause scope.references_values = Array(values[:references]) + Array(preload_values[:references]) - scope.bind_values = (reflection_binds + preload_binds) - scope._select! preload_values[:select] || values[:select] || table[Arel.star] + scope._select! preload_values[:select] || values[:select] || table[Arel.star] scope.includes! preload_values[:includes] || values[:includes] scope.joins! preload_values[:joins] || values[:joins] scope.order! preload_values[:order] || values[:order] diff --git a/activerecord/lib/active_record/associations/preloader/through_association.rb b/activerecord/lib/active_record/associations/preloader/through_association.rb index 816a807f55..56aa23b173 100644 --- a/activerecord/lib/active_record/associations/preloader/through_association.rb +++ b/activerecord/lib/active_record/associations/preloader/through_association.rb @@ -78,10 +78,9 @@ module ActiveRecord if options[:source_type] scope.where! reflection.foreign_type => options[:source_type] else - unless reflection_scope.where_values.empty? + unless reflection_scope.where_clause.empty? scope.includes_values = Array(reflection_scope.values[:includes] || options[:source]) - scope.where_values = reflection_scope.where_values - scope.bind_values = reflection_scope.bind_values + scope.where_clause = reflection_scope.where_clause end scope.references! reflection_scope.values[:references] |