aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation/merger.rb
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-22 17:25:17 -0500
committerRafael Mendonça França <rafaelmfranca@gmail.com>2014-04-22 17:25:17 -0500
commitba84bd933a484e5d365dcf52c9af24ec3937f602 (patch)
tree798a17bea2db1a02a68fb3dc464ff6daf77579bb /activerecord/lib/active_record/relation/merger.rb
parentc26a690b9964d90eea33f33a513ae9c349678cc0 (diff)
parent70b377f4648403b6facbe29b10e179eb649327a9 (diff)
downloadrails-ba84bd933a484e5d365dcf52c9af24ec3937f602.tar.gz
rails-ba84bd933a484e5d365dcf52c9af24ec3937f602.tar.bz2
rails-ba84bd933a484e5d365dcf52c9af24ec3937f602.zip
Merge pull request #14757 from estsauver/14752
Fix behavior of select! to be consistent with select #14752
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