aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/type
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2015-03-23 14:47:24 +1030
committerMatthew Draper <matthew@trebex.net>2015-03-23 15:27:03 +1030
commit8b96c0b7a3510bc2a3ffe183318b7b6bcdf89ff3 (patch)
tree992dfe13f53b82c5fe882d9a43061ead19659f5d /activerecord/lib/active_record/type
parent0347280035db63a43e2103166469ffa93e8e1808 (diff)
downloadrails-8b96c0b7a3510bc2a3ffe183318b7b6bcdf89ff3.tar.gz
rails-8b96c0b7a3510bc2a3ffe183318b7b6bcdf89ff3.tar.bz2
rails-8b96c0b7a3510bc2a3ffe183318b7b6bcdf89ff3.zip
Make sure to persist a newly-nil serialized value
The subtype will (quite reasonably) ignore the possibility that it has `changed_in_place?` by becoming nil. Fixes #19467
Diffstat (limited to 'activerecord/lib/active_record/type')
-rw-r--r--activerecord/lib/active_record/type/serialized.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/type/serialized.rb b/activerecord/lib/active_record/type/serialized.rb
index 732029c723..b22828d371 100644
--- a/activerecord/lib/active_record/type/serialized.rb
+++ b/activerecord/lib/active_record/type/serialized.rb
@@ -28,7 +28,9 @@ module ActiveRecord
def changed_in_place?(raw_old_value, value)
return false if value.nil?
- subtype.changed_in_place?(raw_old_value, serialize(value))
+ raw_new_value = serialize(value)
+ raw_old_value.nil? != raw_new_value.nil? ||
+ subtype.changed_in_place?(raw_old_value, raw_new_value)
end
def accessor