aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/merger.rb
diff options
context:
space:
mode:
authorEarl J St Sauver <estsauver@gmail.com>2014-04-15 21:43:24 -0700
committerEarl St Sauver <estsauver@gmail.com>2014-04-21 14:42:59 -0700
commit70b377f4648403b6facbe29b10e179eb649327a9 (patch)
tree2dad3b20025be364965b0893c9478915e2d1b3c2 /activerecord/lib/active_record/relation/merger.rb
parent43f525031ad3f83a04f84e79bbe1de340bf937aa (diff)
downloadrails-70b377f4648403b6facbe29b10e179eb649327a9.tar.gz
rails-70b377f4648403b6facbe29b10e179eb649327a9.tar.bz2
rails-70b377f4648403b6facbe29b10e179eb649327a9.zip
select! renamed to avoid name collision Array#select!
Fixes #14752 Select mimics the block interface of arrays, but does not mock the block interface for select!. This change moves the api to be a private method, _select!.
Diffstat (limited to 'activerecord/lib/active_record/relation/merger.rb')
-rw-r--r--activerecord/lib/active_record/relation/merger.rb10
1 files changed, 9 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/merger.rb b/activerecord/lib/active_record/relation/merger.rb
index be44fccad5..fcb28a18f6 100644
--- a/activerecord/lib/active_record/relation/merger.rb
+++ b/activerecord/lib/active_record/relation/merger.rb
@@ -30,6 +30,8 @@ module ActiveRecord
else
other.joins!(*v)
end
+ elsif k == :select
+ other._select!(v)
else
other.send("#{k}!", v)
end
@@ -62,7 +64,13 @@ module ActiveRecord
# expensive), most of the time the value is going to be `nil` or `.blank?`, the only catch is that
# `false.blank?` returns `true`, so there needs to be an extra check so that explicit `false` values
# don't fall through the cracks.
- relation.send("#{name}!", *value) unless value.nil? || (value.blank? && false != value)
+ unless value.nil? || (value.blank? && false != value)
+ if name == :select
+ relation._select!(*value)
+ else
+ relation.send("#{name}!", *value)
+ end
+ end
end
merge_multi_values