Skip to content

Commit

Permalink
service/dynamodb/dynamodbattribute: Support string type alias for map…
Browse files Browse the repository at this point in the history
… keys
  • Loading branch information
skmcgrail committed Oct 2, 2019
1 parent fe72a52 commit e396471
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG_PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
* Fixes incorrect modifications to the previous token value of the skipper. Adds checks for cases where a skipped statement should be marked as complete and not be ignored.
* Adds tests for nested and empty field value parsing, along with tests suggested in [#2801](https://github.com/aws/aws-sdk-go/pull/2801)
* Fixes [#2800](https://github.com/aws/aws-sdk-go/issues/2800)
* `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

0 comments on commit e396471

Please sign in to comment.