Repository navigation
Fix DynamoDB Enhanced Client projection expressions for nested list-index paths - #7475
Open
iulianbudau wants to merge 2 commits into
Open
iulianbudau wants to merge 2 commits into
iulianbudau wants to merge 2 commits into
Conversation
This branch has not been deployed
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.
Motivation and Context
Projecting a nested list path such as
NestedAttributeName.create("phoneNumbers[1]", "type")produced an invalidExpressionAttributeNameskey (#AMZN_MAPPED_phoneNumbers[1]). DynamoDB placeholder keys may contain only#followed by[A-Za-z0-9_], so the service rejects the request.DynamoDB document-path rules treat trailing
[n]/[n][m]as list dereferences on the path, not as part of the attribute name token. The expected shape is a projection like#AMZN_MAPPED_phoneNumbers[1].#AMZN_MAPPED_typewith ExpressionAttributeNames mapping only the base names (phoneNumbers,type).Fixes #5603.
Modifications
ProjectionExpressionto peel trailing list-dereference suffixes ([digits]…) from each path element before building placeholders, then re-attach those suffixes in the projection expression string. Parsing is done once per element viaPair<base, suffix>.EnhancedClientUtils.SPECIAL_CHARACTERS/cleanAttributeName(shared by other expression builders).ProjectionExpressionTestfor root/nested/multi-index list paths, special-character bases, placeholder reuse/collision, and malformed non-digit brackets.generateRequestrequest-shape coverage for list projection and filter+projection name merge/collision (ScanOperationTest,QueryOperationTest).ListProjectionExpressionTest; async scan smoke inAsyncListProjectionExpressionTest(EnhancedDocument/documentSchemaBuilder)..changes/next-release/bugfix-AmazonDynamoDBEnhancedClient-5603list.json.Testing
ProjectionExpressionTestcovers root list indexes, nested map/list paths, multi-index suffixes, special-character base names, placeholder reuse/collision, and malformed non-digit brackets.ScanOperationTestandQueryOperationTestassert generatedScanRequest/QueryRequestprojection expression and ExpressionAttributeNames for list-index paths, including filter+projection name merge and conflicting-alias failure.ListProjectionExpressionTestcovers sync scan with filter + list-index projection and sync query with list-index projection;AsyncListProjectionExpressionTestcovers async scan smoke with the same projection path.EnhancedDocumentviaTableSchema.documentSchemaBuilder().Test Coverage Matrix
documentSchemaBuilder/EnhancedDocument; targeted suite passed.AsyncListProjectionExpressionTestasync scan smoke; passed in targeted suite.ListProjectionExpressionTestsync scan + query; passed in targeted suite.ProjectionExpression.phoneNumbers[1].typeprojection covered and passed; invalid projection-name cases not added/verified for this fix.Screenshots (if appropriate)
Types of changes
Checklist
mvn installsucceedsscripts/new-changescript and following the instructions. Commit the new file created by the script in.changes/next-releasewith your changes.License