diff options
author | Sean Griffin <sean@thoughtbot.com> | 2014-10-28 16:57:52 -0600 |
---|---|---|
committer | Sean Griffin <sean@thoughtbot.com> | 2014-10-28 16:57:52 -0600 |
commit | fa7c004df124cbfdc919d5581c83a9c694a0100a (patch) | |
tree | 3d1c8d978e846e7f44770650fdf35a39ed238512 /activerecord | |
parent | d80ed79e99e276708978b9ebd26786bc9a79f46d (diff) | |
download | rails-fa7c004df124cbfdc919d5581c83a9c694a0100a.tar.gz rails-fa7c004df124cbfdc919d5581c83a9c694a0100a.tar.bz2 rails-fa7c004df124cbfdc919d5581c83a9c694a0100a.zip |
Call value methods when merging relations, rather than accessing keys
The change to accessing keys directly was originally added to allow
`merge` to take a hash. The implementation of `HashMerger` no longer
requires us to be doing so. Accessing the values directly makes it
impossible to change internal storage details, even if shim methods are
added temporarily
Diffstat (limited to 'activerecord')
-rw-r--r-- | activerecord/lib/active_record/relation/merger.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb index 545bf5debc..f6bfbe59e2 100644 --- a/activerecord/lib/active_record/relation/merger.rb +++ b/activerecord/lib/active_record/relation/merger.rb @@ -83,12 +83,12 @@ module ActiveRecord private def merge_joins - return if values[:joins].blank? + return if other.joins_values.blank? if other.klass == relation.klass - relation.joins!(*values[:joins]) + relation.joins!(*other.joins_values) else - joins_dependency, rest = values[:joins].partition do |join| + joins_dependency, rest = other.joins_values.partition do |join| case join when Hash, Symbol, Array true @@ -108,10 +108,10 @@ module ActiveRecord def merge_multi_values lhs_wheres = relation.where_values - rhs_wheres = values[:where] || [] + rhs_wheres = other.where_values || [] lhs_binds = relation.bind_values - rhs_binds = values[:bind] || [] + rhs_binds = other.bind_values || [] removed, kept = partition_overwrites(lhs_wheres, rhs_wheres) @@ -133,23 +133,23 @@ module ActiveRecord relation.where_values = where_values relation.bind_values = bind_values - if values[:reordering] + if other.reordering_value # override any order specified in the original relation - relation.reorder! values[:order] - elsif values[:order] + relation.reorder! other.order_values + elsif other.order_values # merge in order_values from relation - relation.order! values[:order] + relation.order! other.order_values end - relation.extend(*values[:extending]) unless values[:extending].blank? + relation.extend(*other.extending_values) unless other.extending_values.blank? end def merge_single_values - relation.from_value = values[:from] unless relation.from_value - relation.lock_value = values[:lock] unless relation.lock_value + relation.from_value = other.from_value unless relation.from_value + relation.lock_value = other.lock_value unless relation.lock_value - unless values[:create_with].blank? - relation.create_with_value = (relation.create_with_value || {}).merge(values[:create_with]) + unless other.create_with_value.blank? + relation.create_with_value = (relation.create_with_value || {}).merge(other.create_with_value) end end |