Skip to content

[DynamoDB bugFix] Fix Key Expression building for renamable sort keys#4357

Merged
muhammad-othman merged 2 commits intoaws:developmentfrom
irina-herciu:bugfix/RenameableSortkey
Mar 23, 2026
Merged

[DynamoDB bugFix] Fix Key Expression building for renamable sort keys#4357
muhammad-othman merged 2 commits intoaws:developmentfrom
irina-herciu:bugfix/RenameableSortkey

Conversation

@irina-herciu
Copy link
Copy Markdown
Contributor

@irina-herciu irina-herciu commented Mar 16, 2026

Use the actual attribute name from PropertyStorage when building range-key expressions to support renamable range/sort keys.

Description

Motivation and Context

Testing

Unit test added

Breaking Changes Assessment

  1. Identify all breaking changes including the following details:
    • What functionality was changed?
    • How will this impact customers?
    • Why does this need to be a breaking change and what are the most notable non-breaking alternatives?
    • Are best practices being followed?
    • How have you tested this breaking change?
  2. Has a senior/+ engineer been assigned to review this PR?

Screenshots (if appropriate)

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

Use the actual attribute name from PropertyStorage when building range-key expressions to support renamable range/sort keys. Updated ContextInternal to pass the PropertyStorage and use its AttributeName in expression attribute name mappings, and adjusted the helper signature accordingly. Added a unit test (TestRenamableAttributeEntity + ConvertQueryConditional_WithRenamableHashAndRangeAttributes_ReturnsValidSearch) and a mock DescribeTableResponse for that entity to validate the fix.
@irina-herciu irina-herciu changed the title [DynamoDB] Fix Key Expression building for renamable sort keys [DynamoDB bugFix] Fix Key Expression building for renamable sort keys Mar 17, 2026
@GarrettBeatty GarrettBeatty requested a review from Copilot March 18, 2026 14:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes DynamoDBContext key-expression generation so range/sort key conditions use the actual DynamoDB attribute name (from PropertyStorage) instead of the CLR property name, enabling renamed sort keys to work correctly.

Changes:

  • Update range-key expression mapping to use rangeKeyProperty.AttributeName when populating ExpressionAttributeNames.
  • Add a unit test covering renamed hash/range key attributes (PK/SK) to validate the generated key expression.
  • Add a DynamoDBv2 patch dev config entry for release automation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs Fixes range-key expression attribute name mapping to use DynamoDB attribute names from model storage.
sdk/test/Services/DynamoDBv2/UnitTests/Custom/DataModel/ContextInternalTests.cs Adds coverage for renamed hash/range key attributes to prevent regressions.
generator/.DevConfigs/1b37806c-0428-4c29-af36-ffb0fb271403.json Declares a patch-level changelog entry for the DynamoDBv2 fix.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs Outdated
Comment thread sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs Outdated
@muhammad-othman
Copy link
Copy Markdown
Member

Pending DRY_RUN-38bb3a4c-fe45-43e9-9c6d-2a08ae43092a.

@@ -1918,14 +1918,13 @@ DocumentModel.Expression MapHashKeyExpression()
return keyExpression1;
}

void MapRangeKeyConditionExpression( RangeKeyCondition rangeKeyCondition, int index,
string rangeKeyPropertyName, PropertyStorage rangeKeyProperty)
void MapRangeKeyConditionExpression(RangeKeyCondition rangeKeyCondition, int index,PropertyStorage rangeKeyProperty)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: whitespace issue on this line

@muhammad-othman muhammad-othman merged commit df49c80 into aws:development Mar 23, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants