-
Notifications
You must be signed in to change notification settings - Fork 867
Features/dynamo db update behavior attribute #4049
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
base: development
Are you sure you want to change the base?
Features/dynamo db update behavior attribute #4049
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds support for the [DynamoDbUpdateBehavior] attribute to the .NET SDK for DynamoDB, enabling control over property update behavior during DynamoDB update operations. The feature aligns with the Java SDK's @DynamoDbUpdateBehavior annotation and introduces an IfNotExists mode that sets property values only when items are created (not on updates), alongside the default Always mode.
Key Changes
- New
DynamoDbUpdateBehaviorAttributeandUpdateBehaviorenum to specify update behavior (Always/IfNotExists) - Updates to the update expression generation logic to support conditional
if_not_existsclauses for properties marked withIfNotExistsbehavior - Integration with existing auto-generated timestamp functionality to enable create-only timestamp tracking
Reviewed Changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| sdk/src/Services/DynamoDBv2/Custom/DataModel/Attributes.cs | Adds new DynamoDbUpdateBehaviorAttribute and UpdateBehavior enum |
| sdk/src/Services/DynamoDBv2/Custom/DataModel/InternalModel.cs | Adds UpdateBehaviorMode property to PropertyStorage and validation logic |
| sdk/src/Services/DynamoDBv2/Custom/DataModel/ContextInternal.cs | Implements GetUpdateIfNotExistsAttributeNames helper to identify properties with IfNotExists behavior |
| sdk/src/Services/DynamoDBv2/Custom/DataModel/Context.cs | Updates save operations to pass IfNotExists attribute names to update helpers |
| sdk/src/Services/DynamoDBv2/Custom/DataModel/TransactWrite.cs | Updates transact write to support IfNotExists attributes |
| sdk/src/Services/DynamoDBv2/Custom/DocumentModel/Table.cs | Modifies UpdateHelper methods to accept and process IfNotExists attribute names |
| sdk/src/Services/DynamoDBv2/Custom/DocumentModel/Util.cs | Updates expression generation to wrap IfNotExists attributes in if_not_exists() function |
| sdk/src/Services/DynamoDBv2/Custom/DocumentModel/Expression.cs | Adds MergeUpdateExpressions method for combining multiple update expressions |
| sdk/src/Services/DynamoDBv2/Custom/DocumentModel/DocumentTransactWrite.cs | Updates transact write document operations to support IfNotExists attributes |
| sdk/src/Services/DynamoDBv2/Custom/DataModel/Utils.cs | Updates error message for validation |
| sdk/test/Services/DynamoDBv2/UnitTests/Custom/DataModel/ContextInternalTests.cs | Adds unit tests for GetUpdateIfNotExistsAttributeNames functionality |
| sdk/test/Services/DynamoDBv2/UnitTests/Custom/DocumentModel/TableTests.cs | New test file covering various update scenarios with and without IfNotExists attributes |
| sdk/test/Services/DynamoDBv2/UnitTests/Custom/DocumentModel/ExpressionsTest.cs | New test file for expression merging functionality |
| sdk/test/Services/DynamoDBv2/IntegrationTests/DataModelTests.cs | Updates integration tests to verify IfNotExists behavior with auto-generated timestamps |
| generator/.DevConfigs/9490947f-209f-47e9-8c70-3698872df304.json | Adds dev config for minor version bump |
|
ill give this a review later this week. thanks for the pr! |
Add support for [DynamoDbUpdateBehavior] attribute to the .NET SDK for DynamoDB, enabling update behavior for a property when performing DynamoDB update operations. This feature aligns with the Java SDK's @DynamoDbUpdateBehavior.
Description
New Attribute: [DynamoDbUpdateBehavior]
Update Behavior Modes:
IfNotExists: Set the value only when the item is created.Always: Set the value on both create and update.Usage:
Motivation and Context
Testing
Screenshots (if appropriate)
Types of changes
Checklist
License