raw type should be able to deserialize#2268
Open
akostadinov wants to merge 1 commit intorsim:masterfrom
Open
Conversation
Collaborator
|
Related to rails/rails#44317 |
Contributor
Author
|
Basically if we always use And if we believe that |
akostadinov
added a commit
to akostadinov/rails
that referenced
this pull request
Apr 18, 2022
`#forgetting_assignment` was introduced with 07723c2, and it involved deserializing and then serializing current value. This is an unnecessary extra operation, and also it is a problem for custom attribute types where `#serialize` and `#deserialize` are not inverse to each other operations. This is a problem for example when using oracle-enhanced-adapter. fixes rails#44317 and rails#42738 and rsim/oracle-enhanced#2268
ActiveRecord expects types to properly deserialize any values that have been serialized. Right now (Rails 7.1) by every object save the attributes are reset by serialize/deserialize cycle. see ActiveModel::ActiveModel#forget_attribute_assignments
Contributor
Author
|
@yahonda , I updated implementation and description of this PR. But now all tests fail for some issue with |
Contributor
Author
|
bump |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
ActiveRecord expects types to properly deserialize any values that
have been serialized. Right now (Rails 7.1) by every object save the
attributes are reset by serialize/deserialize cycle.
see ActiveModel::ActiveModel#forget_attribute_assignments
It might be inefficient but other parts of ActiveRecord and ActiveModel attributes also rely on serialize and deserialize being reversible. At least I saw that
#changed_in_place?expects this to be true in some types like Serialized. So it is rather complicated to change Rails to prevent that.And also it makes intuitive sense that if our class has
#serializeand#deserializemethods, that they reverse each other.So to avoid confusing errors now and going forward, I believe we need this change.
This is more of a hack but I'm not sure of a better way to fix. Provided that we can use#write_lobsfor such inserts, then I don't know why we should serialize and insert with the insert statement thus need the#serialize? Related to #2226I feel there should be a better fix but I'm confused with the whole idea around lob writing.