This project is archived and is in readonly mode.
serialized attributes clobbered on partial updates
-
CancelProfileIsBroken
- Tag set to bugmash
-
Mike Breen
Verified.
-
CancelProfileIsBroken
See #788 partial_updates clobbers serialized attributes for history & discussion
-
Mike Breen
- Assigned user set to Pratik
- Tag changed from bugmash to activerecord, bugmash, dirty, serialized
I've attached a patch that will only save the serialized attribute if it is present in the attributes.
-
Fjan
- Assigned user cleared.
- Tag changed from activerecord, bugmash, dirty, serialized to bugmash
So the gist of the #788 partial_updates clobbers serialized attributes discussion is that partial updates are now always saved because their modification typically cannot detected. The earlier solution that required attribute_changed! to be called on serialised attributes was deemed to be non-intuitive.
This is a dilemma:
- Always saving them causes this serious bug, but is also wasteful because it saves non-changed attributes that are typically large and expensive to serialize - Not saving them trips people up because they don't realize in place modification doesn't update the dirty tracking -
Fjan
- Assigned user set to Pratik
- Tag changed from bugmash to activerecord, bugmash, dirty, serialized
Oops sorry about that last one: we saved at the same time. Thanks for the elegant solution.
-
Repository
- State changed from new to resolved
(from [8056c57a94a2cbbbeb662ebe5b0cc6aa0ca1ef00]) Serialized attributes should only be saved with partial_updates when the serialized attribute is present [#2397 serialized attributes clobbered on partial updates state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/8056c57a94a2cbbbeb662ebe5b0cc6... -
Repository
(from [7d254b5d74144a1e217125e7be21882ce380a3f8]) Serialized attributes should only be saved with partial_updates when the serialized attribute is present [#2397 serialized attributes clobbered on partial updates state:resolved]
Signed-off-by: Pratik Naik pratiknaik@gmail.com
http://github.com/rails/rails/commit/7d254b5d74144a1e217125e7be2188... -
CancelProfileIsBroken
- Assigned user cleared.
- Tag changed from activerecord, bugmash, dirty, serialized to activerecord, dirty, serialized
- Milestone cleared.
-
Neil Spring
Could this patch be changed from:
update_without_dirty(changed | (attributes.keys & self.class.serialized_attributes.keys))
to:
update_without_dirty(changed | (attribute_names & self.class.serialized_attributes.keys))
I believe the two have the same effect. For me, attributes.keys requires reading all attributes to fill in the values. I'm continuing to port old software written when ModelSecurity worked well, and reading all elements of a record is not permitted. For others, going directly to the attribute names should be more efficient.
