fix: correct the transaction write for put correctly.#175
Merged
Conversation
Contributor
Author
|
@copilot update the PR description |
Contributor
8 tasks
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a bug in the transactWriteItems function where ExpressionAttributeValues was being unconditionally assigned even when empty for Put operations. The fix ensures that DynamoDB EXISTS operations (which don't require attribute values) correctly omit the ExpressionAttributeValues field when it's empty.
Key changes:
- Added conditional check to only set
ExpressionAttributeValuesfor Put operations when values exist - Moved
buildConditionExpressionsto sharedexpressionBuilder.tsmodule to eliminate code duplication - Added support for
EXISTSoperator inbuildConditionExpressionsto properly handle attribute existence checks - Updated tests to reflect correct behavior (empty
ExpressionAttributeValuesobject or omitted entirely)
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/mutation/transactWriteItems.ts | Added conditional check to only assign ExpressionAttributeValues when non-empty for Put operations |
| src/mutation/transactWriteItems.spec.ts | Updated test expectations to reflect proper handling of EXISTS conditions (no attribute values needed) |
| src/mutation/putItem.ts | Refactored to use shared buildConditionExpressions from expressionBuilder module |
| src/mutation/expressionBuilder.ts | Added EXISTS operator support to handle attribute_exists and attribute_not_exists without values |
| package.json | Version bump from 0.6.2 to 0.6.3 |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
This PR fixes a bug in the transactWriteItems function where ExpressionAttributeValues was being unconditionally assigned even when empty for Put operations. The fix ensures that DynamoDB EXISTS operations (which don't require attribute values) correctly omit the ExpressionAttributeValues field when it's empty.
Key changes:
Added conditional check to only set ExpressionAttributeValues for Put operations when values exist
Moved buildConditionExpressions to shared expressionBuilder.ts module to eliminate code duplication
Added support for EXISTS operator in buildConditionExpressions to properly handle attribute existence checks
Updated tests to reflect correct behavior (empty ExpressionAttributeValues object or omitted entirely)
Related Issues
Issue: #XXX
How Has This Been Tested
Unit tests
Types of changes
Checklist
Screenshots (if appropriate)
N/A