diff --git a/feature/dynamodb/attributevalue/field.go b/feature/dynamodb/attributevalue/field.go index 4f63bc7df99..f3ead32162a 100644 --- a/feature/dynamodb/attributevalue/field.go +++ b/feature/dynamodb/attributevalue/field.go @@ -128,7 +128,7 @@ func enumFields(t reflect.Type, opts structFieldOptions) []field { structField := buildField(f.Index, i, sf, fieldTag) structField.Type = ft - if !sf.Anonymous || ft.Kind() != reflect.Struct { + if !sf.Anonymous || fieldTag.Name != "" || ft.Kind() != reflect.Struct { fields = append(fields, structField) if count[f.Type] > 1 { // If there were multiple instances, add a second, diff --git a/feature/dynamodb/attributevalue/marshaler_test.go b/feature/dynamodb/attributevalue/marshaler_test.go index 6d895e89b4a..fa810728ea9 100644 --- a/feature/dynamodb/attributevalue/marshaler_test.go +++ b/feature/dynamodb/attributevalue/marshaler_test.go @@ -636,6 +636,10 @@ func BenchmarkUnmarshalTwoMembers(b *testing.B) { } func Test_Encode_YAML_TagKey(t *testing.T) { + type Embedded struct { + String string `yaml:"string"` + } + input := struct { String string `yaml:"string"` EmptyString string `yaml:"empty"` @@ -649,6 +653,7 @@ func Test_Encode_YAML_TagKey(t *testing.T) { Slice []string `yaml:"slice"` Map map[string]int `yaml:"map"` NoTag string + Embedded `yaml:"embedded"` }{ String: "String", Ignored: "Ignored", @@ -658,6 +663,9 @@ func Test_Encode_YAML_TagKey(t *testing.T) { "two": 2, }, NoTag: "NoTag", + Embedded: Embedded{ + String: "String", + }, } expected := &types.AttributeValueMemberM{ @@ -682,6 +690,11 @@ func Test_Encode_YAML_TagKey(t *testing.T) { }, }, "NoTag": &types.AttributeValueMemberS{Value: "NoTag"}, + "embedded": &types.AttributeValueMemberM{ + Value: map[string]types.AttributeValue{ + "string": &types.AttributeValueMemberS{Value: "String"}, + }, + }, }, } diff --git a/feature/dynamodbstreams/attributevalue/field.go b/feature/dynamodbstreams/attributevalue/field.go index 4f63bc7df99..f3ead32162a 100644 --- a/feature/dynamodbstreams/attributevalue/field.go +++ b/feature/dynamodbstreams/attributevalue/field.go @@ -128,7 +128,7 @@ func enumFields(t reflect.Type, opts structFieldOptions) []field { structField := buildField(f.Index, i, sf, fieldTag) structField.Type = ft - if !sf.Anonymous || ft.Kind() != reflect.Struct { + if !sf.Anonymous || fieldTag.Name != "" || ft.Kind() != reflect.Struct { fields = append(fields, structField) if count[f.Type] > 1 { // If there were multiple instances, add a second, diff --git a/feature/dynamodbstreams/attributevalue/marshaler_test.go b/feature/dynamodbstreams/attributevalue/marshaler_test.go index ac0969111aa..beb3d86e82d 100644 --- a/feature/dynamodbstreams/attributevalue/marshaler_test.go +++ b/feature/dynamodbstreams/attributevalue/marshaler_test.go @@ -636,6 +636,10 @@ func BenchmarkUnmarshalTwoMembers(b *testing.B) { } func Test_Encode_YAML_TagKey(t *testing.T) { + type Embedded struct { + String string `yaml:"string"` + } + input := struct { String string `yaml:"string"` EmptyString string `yaml:"empty"` @@ -649,6 +653,7 @@ func Test_Encode_YAML_TagKey(t *testing.T) { Slice []string `yaml:"slice"` Map map[string]int `yaml:"map"` NoTag string + Embedded `yaml:"embedded"` }{ String: "String", Ignored: "Ignored", @@ -658,6 +663,9 @@ func Test_Encode_YAML_TagKey(t *testing.T) { "two": 2, }, NoTag: "NoTag", + Embedded: Embedded{ + String: "String", + }, } expected := &types.AttributeValueMemberM{ @@ -682,6 +690,11 @@ func Test_Encode_YAML_TagKey(t *testing.T) { }, }, "NoTag": &types.AttributeValueMemberS{Value: "NoTag"}, + "embedded": &types.AttributeValueMemberM{ + Value: map[string]types.AttributeValue{ + "string": &types.AttributeValueMemberS{Value: "String"}, + }, + }, }, }