-
Notifications
You must be signed in to change notification settings - Fork 642
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
dynamodb/attributevalue: Add utility to (un)marshal Attribtue Values #948
Conversation
dab9029
to
fded929
Compare
132bcfc
to
a852eef
Compare
Adds support for * Fixes aws#895 - Add support for attribute value marshaling * Fixes aws#929 - Support Number type aliases of string for support for json.Number like types. * Fixes aws#115 - Simplifies the rules of `null` vs skipped vs zero value for all types. * All nil pointers, map, slice members are serialized as NULL. * omitempty struct tag skips zero value of members with the struct tag. * Empty and Nil Sets (NS, BS, SS) are serialized to null by default unless `NullEmptySets` EncoderOptions is set to false. True by default. Nil sets are always serialized as NULL, unless the `omitempty` struct tag is used. * Adds `nullempty` and `nullemptyelem` struct tags to direct if the encoder should marshal the member as a AttributeValue NULL if the member's value is the type's zero value, (e.g. "" for string, 0 for number, nil for pointer/map/slice, false for bool)
_, isNull := av.(*types.AttributeValueMemberNULL) | ||
if av == nil || isNull { |
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.
If av is not nil and the type is AttributeValueMemberNULL
should this check that av.Value == true
?
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.
It would be odd if it was set to false, but it's the more correct check.
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.
We could check if Value
is false. I'll check if Dynamo looks at this value. I had a feeling it ignored or always set the value to true on its side. A value of false doesn't really have any clear meaning. (Other than potentially error)
Adds utilities for mapping Amazon DynamoDB API AttributeValue to and from Go types.
Adds conversion util for DynamoDB -> DynamoDBStreams AttributeValue.
Fixes dynamodb/attributevalue: Add AttributeValue marshaler utilities #895 - Adds back marshaler/unmarshalers for attribute value to/from go types.
Fixes dynamodb/attributevalue: Marshal does not support json.Number to Numeric data type #929 - Adds generic support for
json.Number
like types that are aliases ofstring
s.Fixes dynamodb/attributevalue: Consider changing default behavior for empty maps and slices #115 - Simplifies the rules of
null
vs skipped vs zero valuefor all types.
omitempty
struct tag skips zero value of members with the struct tag.omitemptyelem
skips elements of list/map that have zero value.nullempty
struct tag serializes zero value of members with the struct tag as NULL AttributeValue.nullemptyelem
does same for elements of list/map that have zero value.NullEmptySets
EncoderOptions is set to false. True by default. Nil sets are always serialized as NULL, unless theomitempty
struct tag is used.nullempty
andnullemptyelem
struct tags to direct if the encoder should marshal the member as a AttributeValue NULL if the member's value is the type's zero value, (e.g. "" for string, 0 for number, nil for pointer/map/slice, false for bool)TODO: