fix: Delay the cast from IAmazonDynamoDB to AmazonDynamoDBClient in the DocumentModel #3388
Merged
ashovlin merged 4 commits intov4-developmentfrom Aug 8, 2024
Merged
fix: Delay the cast from IAmazonDynamoDB to AmazonDynamoDBClient in the DocumentModel #3388ashovlin merged 4 commits intov4-developmentfrom
ashovlin merged 4 commits intov4-developmentfrom
Conversation
normj
approved these changes
Jul 23, 2024
Member
normj
left a comment
There was a problem hiding this comment.
A couple minor nits but change looks good.
| var serviceResponse = client.BatchGetItem(request); | ||
| #if AWS_ASYNC_API | ||
| // Cast the IAmazonDynamoDB to the concrete client instead, so we can access the internal sync-over-async methods | ||
| var internalClient = client as AmazonDynamoDBClient; |
Member
There was a problem hiding this comment.
nit: You can move the casting logic outside of the loop and only do it once.
| { | ||
| var result = client.BatchWriteItem(request); | ||
| #if AWS_ASYNC_API | ||
| // Cast the IAmazonDynamoDB to the concrete client instead, so we can access the internal sync-over-async methods |
Member
There was a problem hiding this comment.
nit: Move the casting logic above the loop.
philasmar
approved these changes
Jul 24, 2024
Member
Author
|
Realized that I was using too wide of a condition This also made some .NET Framework tests invalid, so I removed them. |
normj
approved these changes
Aug 2, 2024
philasmar
approved these changes
Aug 5, 2024
…mazon.DynamoDBv2.DocumentModel to only when it's necessary for sync-over-async code paths. This allows mocking for async callers.
c8176aa to
9fa85ad
Compare
normj
approved these changes
Aug 7, 2024
Member
Author
|
Dry-run e8acaff2-7604-4ade-a913-8ea4cc934cfe passed after adding 2f8a80e |
This was referenced Aug 8, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Before: When initializing the document model
Tableobject with anIAmazonDynamoDB, .NET/Standard/Core, we cast it right away to anAmazonDynamoDBClient.TableAPIs, which still rely on the internal sync low-level APIs internally.internalonAmazonDynamoDBClient. This is why we need the cast, since the sync low-level APIs are no longer part of the publicIAmazonDynamoDB.Now: We delay the cast until right before we need to access the internal, low-level sync APIs.
AmazonDynamoDBClient, you'll now see a clearerInvalidOperationExceptioninstead of theNullReferenceExceptionfrom the failed cast.Future:
Tablesync-over-async APIs entirely. This would remove the need for this cast.Motivation and Context
DOTNET-6755 and #1589 (most of the way, until we do on of the Future ideas from above)
This allows
Tableconsumers to mock theIAmazonDynamoDBfrom .NET/Standard/Core as long as you stick to async public APIs.Testing
PENDING - .NET Standard integ tests for DDB
Types of changes
Checklist
License