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 string type alias for map… #2870

Merged
merged 2 commits into from
Oct 3, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
### SDK Enhancements

### SDK Bugs
* `service/dynamodb/dynamodbattribute`: Fixes a panic when decoding into a map with a key string type alias. ([#2870](https://github.com/aws/aws-sdk-go/pull/2870))
3 changes: 2 additions & 1 deletion service/dynamodb/dynamodbattribute/decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,8 @@ func (d *Decoder) decodeMap(avMap map[string]*dynamodb.AttributeValue, v reflect

if v.Kind() == reflect.Map {
for k, av := range avMap {
key := reflect.ValueOf(k)
key := reflect.New(v.Type().Key()).Elem()
key.SetString(k)
elem := reflect.New(v.Type().Elem()).Elem()
if err := d.decode(av, elem, tag{}); err != nil {
return err
Expand Down
8 changes: 8 additions & 0 deletions service/dynamodb/dynamodbattribute/shared_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type testAliasedStruct struct {

Value13 testAliasedBool
Value14 testAliasedBoolSlice

Value15 map[testAliasedString]string
}

type testNamedPointer *int
Expand Down Expand Up @@ -256,6 +258,9 @@ var sharedTestCases = []struct {
{BOOL: aws.Bool(false)},
{BOOL: aws.Bool(true)},
}},
"Value15": {M: map[string]*dynamodb.AttributeValue{
"TestKey": {S: aws.String("TestElement")},
}},
},
},
actual: &testAliasedStruct{},
Expand All @@ -278,6 +283,9 @@ var sharedTestCases = []struct {
Value12: testAliasedStringSlice{"1", "2", "3"},
Value13: true,
Value14: testAliasedBoolSlice{true, false, true},
Value15: map[testAliasedString]string{
"TestKey": "TestElement",
},
},
},
{
Expand Down