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

Use encoding.TextMarshaler and encoding.TextUnmarshaler in DynamoDB attributevalue marshalers/unmarshalers, if available #2596

Open
1 of 2 tasks
alexwennerberg opened this issue Apr 3, 2024 · 1 comment
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue queued This issues is on the AWS team's backlog

Comments

@alexwennerberg
Copy link

Describe the feature

When DynamoDB attributevalue marshals or unmarshals a struct, look to see if that struct implements encoding.TextMarshaler and encoding.TextUnmarshaler interfaces, and use them if available.

Use Case

When dynamodb's attributevalue marshals and unmarshals a custom type, it requires that you implement the attributevalue.Marshaler interface on that type. This is somewhat awkward and requires dynamodb-specific code on a type that may have nothing to do with dynamodb, or it requires building some sort of wrapper marshaller
In many cases, all that we want to do is unmarshal or marshal a custom type as a dynamodb string (ie, a subfield of a struct that MarshalMap is being called upon, representing a DynamoDB record), thus we should be able to implement encoding/text's interfaces on our custom type interface that looks to see if a type has implemented this interface and, if so, use it to marshal (or unmarshal) to/from a dynamodb type using that interface, much like the https://cs.opensource.google/go/go/+/refs/tags/go1.22.1:src/encoding/json/encode.go;l=36 encoding/json package does

Proposed Solution

Update attributevalue's Marshaler and Unmarshaler to try, in addition to the attributevalue.Marshal interface, the encoding.Marshal interface, converting to and from an AttributeValueMemberS.

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

AWS Go SDK V2 Module Versions Used

1.13.13

Go version used

1.22.1

@alexwennerberg alexwennerberg added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Apr 3, 2024
@RanVaknin RanVaknin added p2 This is a standard priority issue queued This issues is on the AWS team's backlog and removed needs-triage This issue or PR still needs to be triaged. labels Apr 4, 2024
@RanVaknin
Copy link
Contributor

Adding to backlog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request A feature should be added or improved. p2 This is a standard priority issue queued This issues is on the AWS team's backlog
Projects
None yet
Development

No branches or pull requests

2 participants