Skip to content
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

service/dynamodb/dynamodbattribute: Support for configuring the marsh… #2834

Merged
merged 2 commits into from
Sep 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
### SDK Features
* `service/dynamodb/dynamodbattribute`: Add EnableEmptyCollections flag to Encoder and Decoder ([#2834](https://github.com/aws/aws-sdk-go/pull/2834))
* The `Encoder` and `Decoder` types have been enhanced to allow support for specifying the SDK's behavior when marshaling structures, maps, and slices to DynamoDB.
* When `EnableEmptyCollections` is set to `True` the SDK will preserve the empty of these types in DynamoDB rather then encoding a NULL AttributeValue.
* Fixes [#682](https://github.com/aws/aws-sdk-go/issues/682)
* Fixes [#1890](https://github.com/aws/aws-sdk-go/issues/1890)
* Fixes [#2746](https://github.com/aws/aws-sdk-go/issues/2746)
* `service/s3/s3manager`: Add Download Buffer Provider ([#2823](https://github.com/aws/aws-sdk-go/pull/2823))
* Adds a new `BufferProvider` member for specifying how part data can be buffered in memory when copying from the http response body.
* Windows platforms will now default to buffering 1MB per part to reduce contention when downloading files.
Expand Down
16 changes: 9 additions & 7 deletions service/dynamodb/dynamodbattribute/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"strconv"
"time"

"github.com/aws/aws-sdk-go/aws"
"github.com/aws/aws-sdk-go/service/dynamodb"
)

Expand Down Expand Up @@ -155,6 +156,7 @@ var byteSliceType = reflect.TypeOf([]byte(nil))
var byteSliceSlicetype = reflect.TypeOf([][]byte(nil))
var numberType = reflect.TypeOf(Number(""))
var timeType = reflect.TypeOf(time.Time{})
var ptrStringType = reflect.TypeOf(aws.String(""))

func (d *Decoder) decode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag tag) error {
var u Unmarshaler
Expand All @@ -172,23 +174,23 @@ func (d *Decoder) decode(av *dynamodb.AttributeValue, v reflect.Value, fieldTag
}

switch {
case len(av.B) != 0:
case len(av.B) != 0 || (av.B != nil && d.EnableEmptyCollections):
return d.decodeBinary(av.B, v)
case av.BOOL != nil:
return d.decodeBool(av.BOOL, v)
case len(av.BS) != 0:
case len(av.BS) != 0 || (av.BS != nil && d.EnableEmptyCollections):
return d.decodeBinarySet(av.BS, v)
case len(av.L) != 0:
case len(av.L) != 0 || (av.L != nil && d.EnableEmptyCollections):
return d.decodeList(av.L, v)
case len(av.M) != 0:
case len(av.M) != 0 || (av.M != nil && d.EnableEmptyCollections):
return d.decodeMap(av.M, v)
case av.N != nil:
return d.decodeNumber(av.N, v, fieldTag)
case len(av.NS) != 0:
case len(av.NS) != 0 || (av.NS != nil && d.EnableEmptyCollections):
return d.decodeNumberSet(av.NS, v)
case av.S != nil:
case av.S != nil: // DynamoDB does not allow for empty strings, so we do not consider the length or EnableEmptyCollections flag here
return d.decodeString(av.S, v, fieldTag)
case len(av.SS) != 0:
case len(av.SS) != 0 || (av.SS != nil && d.EnableEmptyCollections):
return d.decodeStringSet(av.SS, v)
}

Expand Down
Loading