-
Notifications
You must be signed in to change notification settings - Fork 916
DDB Enhanced: Expose attribute extractors and converters #1757
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
DDB Enhanced: Expose attribute extractors and converters #1757
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1757 +/- ##
============================================
- Coverage 76.31% 76.30% -0.02%
Complexity 182 182
============================================
Files 1072 1072
Lines 32247 32250 +3
Branches 2519 2519
============================================
- Hits 24608 24607 -1
- Misses 6400 6402 +2
- Partials 1239 1241 +2
Continue to review full report at Codecov.
|
Hi @musketyr, thank you for taking a look at the enhanced client preview and also submitting your contribution to improve the experience. Before really drilling on the change itself I first need to make sure I understand the motivation and what it is you are trying to do because generally speaking we are very resistant to making internal interfaces public unless absolutely necessary as that restricts what we can do with those interfaces in the future, so the cost is high. Based on your description of your use-case it sounds like you are trying to apply a TableSchema to extract and convert one or more object modeled attributes to their AttributeValue equivalents that would be written to the DynamoDB table if you were doing, say, a PutItem? If that is true, is this existing method in TableSchema not sufficient to accomplish that?
|
Also, to convert and retrieve a single AttributeValue you can use:
|
Hi @bmaizels, thank you for a quick answer! The motivation is to reimplement advanced queries and updates using the declarative clients in Micronaut. There is a working version using v1. https://agorapulse.github.io/micronaut-aws-sdk/#_declarative_services_with_service If you take a look at the
I would like to convert the values
With the new exposed API, it would be much easier:
This approach is much cleaner, it uses the information already present in the metamodel, it is reflection-free and it avoids unnecessary object creation. |
@musketyr Thanks for explaining better, I understand what you are trying to do now and why you are trying to do it. Having said that I'm still hesitant to approve making these interfaces public for the aforementioned reasons. Please give me some time to think on it and discuss with my team and see if we can come up with any other ideas about how to solve this for you. |
My initial thoughts is this use-case might be better served by the Document API we are planning to release as part of the DDB Enhanced Client. I'll get back to you. |
Thank you! I'm just wondering, would it be more acceptable for you to add the |
Kudos, SonarCloud Quality Gate passed!
|
This is a very old issue that is probably not getting as much attention as it deserves. We encourage you to check if this is still an issue in the latest release and if you find that this is still a problem, please feel free to provide a comment or open a new issue. |
Description
This PR exposes the
Attribute
andAttributeType
API from theTableSchema
to alloweasier generalization of the construction of queries.
Motivation and Context
In version 1, there were API to convert the Java value to the
AttributeValue
(DynamoDBMapperFieldModel
) which is not present in version 2.See RangeConditionCollector for an example usage with version 1. Exposing the already present information about the attributes enables reimplementing similar behaviour for version 2.
Testing
The main problem with this PR might be that
AttributeType
has been moved to the public API so the package has been changed. This might break some existing applications which ignored thatAttributeType
was a internal API so far.Screenshots (if appropriate)
Types of changes
NOTE: this change is making an internal interface into public one which may break some existing 3rd party code which relies on the internal API. As the interface was marked as internal before then it should be considered non-breaking change.
Checklist
mvn install
succeedsLicense