-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow attributes to be marshalled for relations #12
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering - is the special allowattrs
field tag annotation necessary? It seems like we could do "If the primary ID field isn't set, any fields which are 1) not the primary ID or type attr and 2) Not zero value (omitempty) should then be included in the marshaling. "
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👨🍳 💋 Nice work!
According to the spec, relationships must have both an
id
andtype
field be present. However, this limits the ability to perform certain actions such as creating records via the relationship at the same time as the root record.This PR modifies
toShallowNode
to allow for attributes to be allocated if theID
has a zero value (""
). It's worth noting that if the struct sent has a primary type that is not astring
(eg. anint
), the zero value check will fail as theID
will be"0". It was determined to be a reasonable issue to have as
go-tfemakes no use of non-string
ID` types.Test Results