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.
I'm using a custom serializer that does not store nil values. I noticed that the attributes are stored correctly, but then not correctly reified back. For example:
After some digging, I found that the problem is in
#reify
. The current version of the model is reused, and each attribute from the previous version is set on the current model. However, since "name" is not a key in the previous version, name was left as "Bob."This was not a problem in the default serializers provided. Because they store everything, both versions of the models have all the same keys. For example:
This patch compares the keys between the current model and the previous version. If any keys are found to be missing, it puts them in as nil. This allows those attributes to be set to nil on the reified model.
I updated the serializer tests so they separately test the built-in JSON serializer as well as a custom serializer which doesn't store nil keys.