aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@thoughtbot.com>2015-01-25 16:10:56 -0700
committerSean Griffin <sean@thoughtbot.com>2015-01-25 16:11:07 -0700
commit4d7a62293e148604045a5f78a9d4312e79e90d13 (patch)
tree8204e4a2dff6cda9789d28dc0cc098bae78c4fa2 /activerecord/lib
parentffd495cf2131dd8b3fc1ec619c996c3002c23714 (diff)
downloadrails-4d7a62293e148604045a5f78a9d4312e79e90d13.tar.gz
rails-4d7a62293e148604045a5f78a9d4312e79e90d13.tar.bz2
rails-4d7a62293e148604045a5f78a9d4312e79e90d13.zip
Don't rely as much on the structure of the values hash in associations
The structure of `values[:where]` is going to change, with an intermediate definition of `where_values` to aid the refactoring. Accessing `values[:where]` directly messes with that, signficantly. The array wrapping is no longer necessary, since `where_values` will always return an array.
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/associations/preloader.rb2
-rw-r--r--activerecord/lib/active_record/associations/preloader/association.rb2
2 files changed, 2 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb
index 4358f3b581..0a5ef601a2 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).new({}, [])
+ NULL_RELATION = Struct.new(:values, :bind_values, :where_values).new({}, [], [])
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 afcaa5d55a..8f001770f7 100644
--- a/activerecord/lib/active_record/associations/preloader/association.rb
+++ b/activerecord/lib/active_record/associations/preloader/association.rb
@@ -136,7 +136,7 @@ module ActiveRecord
preload_values = preload_scope.values
preload_binds = preload_scope.bind_values
- scope.where_values = Array(values[:where]) + Array(preload_values[:where])
+ scope.where_values = reflection_scope.where_values + preload_scope.where_values
scope.references_values = Array(values[:references]) + Array(preload_values[:references])
scope.bind_values = (reflection_binds + preload_binds)