aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorSean Griffin <sean@seantheprogrammer.com>2016-06-02 11:32:05 -0400
committerSean Griffin <sean@seantheprogrammer.com>2016-06-02 11:34:48 -0400
commitc587b636648394e33292ba8ba47d22bdad7446c3 (patch)
treedbd607c0e8ea3df407dc1dfd828843a863783e93 /activerecord/lib
parentb604dd0b81c44c3b4605f31e8f4b914fa7686b1a (diff)
downloadrails-c587b636648394e33292ba8ba47d22bdad7446c3.tar.gz
rails-c587b636648394e33292ba8ba47d22bdad7446c3.tar.bz2
rails-c587b636648394e33292ba8ba47d22bdad7446c3.zip
Ensure that records with unselected fields can be updated
As part of refactoring mutation detection to be more performant, we introduced the concept of `original_value` to `Attribute`. This was not overridden in `Attribute::Uninitialized` however, so assigning ot an uninitialized value and calling `.changed?` would raise `NotImplementedError`. We are using a sentinel value rather than checking the result of `original_attribute.initialized?` in `changed?` because `original_value` might go through more than one node in the tree. Fixes #25228
Diffstat (limited to 'activerecord/lib')
-rw-r--r--activerecord/lib/active_record/attribute.rb6
1 files changed, 6 insertions, 0 deletions
diff --git a/activerecord/lib/active_record/attribute.rb b/activerecord/lib/active_record/attribute.rb
index cacde0f6fd..9530f134d0 100644
--- a/activerecord/lib/active_record/attribute.rb
+++ b/activerecord/lib/active_record/attribute.rb
@@ -205,6 +205,8 @@ module ActiveRecord
end
class Uninitialized < Attribute # :nodoc:
+ UNINITIALIZED_ORIGINAL_VALUE = Object.new
+
def initialize(name, type)
super(name, nil, type)
end
@@ -215,6 +217,10 @@ module ActiveRecord
end
end
+ def original_value
+ UNINITIALIZED_ORIGINAL_VALUE
+ end
+
def value_for_database
end