Releases: guregu/dynamo
Batch get and empty sets fix
This is a bugfix release that resolves an issue where BatchGet would return ErrNotFound early upon encountering an empty set of 100 results (#161). Thanks @Dave-Dohmeier!
Expression wrapping fix
Update.Set auto-omit fix
Number sets fix
This is a minor release that fixes an issue with decoding number sets (#150). Thanks to @aoldershaw for the contribution.
New Update features and AWSEncoding fixes
This release adds Update.DeleteFromSet
which can be useful for deleting values from sets not covered by the pre-existing helper methods (#146). Also, Update.OnlyUpdatedValue
and Update.OnlyUpdatedOldValue
have been added, which are the equivalents of UPDATED_NEW
and UPDATED_OLD
and encode only the values that have been changed from an update (#142).
AWSEncoding
support has been improved (#147). You can now use it with methods that operate on slices, such as:
var list []myAWSEncodedStuff
table.Get("UserID", 123).All(dynamo.AWSEncoding(&list))
This release also bumps up aws-sdk-go to the latest version.
Thanks to everyone who reported issues and sent PRs, and to everyone who uses this library.
Encoding improvements
Improved support for null and empty values
This release improves and extends many areas of the encoder, improving support for empty and null values and fixing some important issues.
We can now take advantage of DynamoDB's support for empty strings and binary attributes!
- Added support for empty/null values in DynamoDB lists (slices and arrays) and sets (slices or maps with the
dynamo:",set"
struct tag option). By default, empty strings and binary values are encoded as-is, and nil pointers are set to a DynamoDB NULL type. Previously these cases were a SerializationException. Fixes #102 and #137.- Added a new struct tag option
dynamo:",omitemptyelem"
that omits these values instead. Note that this will mess up your array indexes.
- Added a new struct tag option
- Added a new struct tag option
dynamo:",allowempty"
to disable auto-omit behavior for empty string or binary field values. Keep in mind that primary keys can't be empty. - Added a new struct tag option
dynamo:",allowemptyelem"
to disable auto-omit behavior for empty string, empty binary, and nil values in maps. - Added a new struct tag option
dynamo:",null"
that will marshal nil or empty values to DynamoDB NULL types. Whenallowempty
is also set,allowempty
will take precedence. - Added
Update.SetNullable
which isUpdate.Set
without automatic empty/nil removal. - Added support for empty/nil arguments in
If
andFilter
. - Added support for custom empty structs in sets: #133, thanks @finnbear.
- Docs improvements: #123, #136. Thanks @ZacharyGroff and @d-tsuji.
This release should have total backwards compatibility with previous versions. New support for empty/nil values was added in areas that were previously serialization errors. Auto-omit behavior was kept the same, but now you can use allowempty
and allowemptyelem
to disable it.
Example:
var widget = struct {
HashKey string
Desc string `dynamo:",allowempty"`
Words []string
Ptr *int `dynamo:",null"`
}{
HashKey: "abc",
Desc: "",
Words: []string{"hello", "world", ""},
Ptr: nil,
}
will be marshaled like so
{
HashKey: {S: "abc"},
Desc: {S: ""},
Words: {L: [{S: "hello"}, {S: "world"} {S: ""}]},
Ptr: {NULL: true},
}
Big thanks to everyone who submitted issues and PRs, and all the users of this library.
Custom item marshaling
This release adds ItemMarshaler
and ItemUnmarshaler
, which are interfaces allowing for total control of item marshaling. This is useful for handling dynamic items whose structure depends on its content. Thanks to @luma for submitting this in PR #126!
// ItemMarshaler is the interface implemented by objects that
// can marshal themselves into an Item (a map of strings
// to AttributeValues).
type ItemMarshaler interface {
MarshalDynamoItem() (map[string]*dynamodb.AttributeValue, error)
}
// ItemUnmarshaler is the interface implemented by
// objects that can unmarshal an Item (a map of strings
//to AttributeValues) into themselves.
type ItemUnmarshaler interface {
UnmarshalDynamoItem(item map[string]*dynamodb.AttributeValue) error
}
AWSEncoding fixes
This release fixes a bug where AWSEncoding items were not being (un)marshaled properly in Put, Get, etc (#125).
The module dependency on aws-sdk-go was also updated to the latest version.
Improved array handling ②
This release fixes unmarshaling to return an error when unmarshaling a DynamoDB list into an array that is too small.
See notes for v1.7.1, which includes a similar fix for DynamoDB binary data.