Merged
Conversation
netramali
commented
Feb 3, 2025
| RFC3339Time NullableAttr[time.Time] `jsonapi:"attr,rfc3339_time,rfc3339,omitempty"` | ||
| ISO8601Time NullableAttr[time.Time] `jsonapi:"attr,iso8601_time,iso8601,omitempty"` | ||
| Bool NullableAttr[bool] `jsonapi:"attr,bool,omitempty"` | ||
| NullableComment NullableRelationship[*Comment] `jsonapi:"relation,nullable_comment,omitempty"` |
Collaborator
Author
There was a problem hiding this comment.
This is the intended usage.
By setting the NullableRelationship to an explicit value it will serialize that value, by setting the NullableRelationship to an explicit null will serialize a null value which is intended to clear the relationship.
netramali
commented
Feb 3, 2025
| } else { | ||
| node.Relationships[args[1]] = json.RawMessage("{\"data\":null}") | ||
| } | ||
| return nil |
Collaborator
Author
There was a problem hiding this comment.
Karl originally had continue here instead of return but it was giving me an error suggesting that we should use return instead.
ctrombley
reviewed
Feb 4, 2025
ctrombley
left a comment
There was a problem hiding this comment.
This is looking good! Just a few minor comments.
mkam
reviewed
Feb 4, 2025
Co-authored-by: Chris Trombley <ctrombley@gmail.com>
Co-authored-by: Chris Trombley <ctrombley@gmail.com>
Co-authored-by: Chris Trombley <ctrombley@gmail.com>
4316bbf to
e123c06
Compare
mkam
approved these changes
Feb 5, 2025
mukeshjc
approved these changes
Feb 7, 2025
This was referenced Apr 2, 2025
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.
http://jsonapi.org/format/#document-resource-object-relationships
http://jsonapi.org/format/#document-resource-object-linkage
Relationships can have a data node set to null (e.g. to disassociate the relationship)
The NullableRelationship type allows this data to be serialized/de-serialized. When serialized, a NullableRelationship with an explicit null will serialize to the appropriate "null" type. Either '"data": null' or '[]'.
Supports slice and regular reference types for serialization, and regular reference types for de-serialization.
The reason to not support slices for de-serialization is we need to decide how to handle the zero type for a NullableRelationship[[]*...] slice. Since we aren't using this and can emulate the nulling behavior by omitting omit-empty we decided to ignore this case for now.
Related commits:
1st Commit
2nd Commit
Reference PR