Does DynamoDb update a record if no changes have been made in an UpdateItemRequest?
For example, if the table contains a record as follows:
{
"id": "1",
"name": "alice"
}
And the update request is as follows:
String expression = "set #n = :n"
HashMap<String, String> expressionAttributeNames = new HashMap<>();
expressionAttributeNames.put("#n", "name");
HashMap<String, AttributeValue> expressionAttributeValues = new HashMap<>();
expressionAttributeValues.put(":n", AttributeValue.builder().s("alice").build());
UpdateItemRequest updateItemRequest =
UpdateItemRequest.builder()
.tableName(tableName)
.key(key)
.updateExpression(expression)
.expressionAttributeNames(expressionAttributeNames)
.expressionAttributeValues(expressionAttributeValues)
.build();
dynamoDbClient.updateItem(updateItemRequest);
In this case the name remains "alice", nothing has been changed. Does DynamoDb treat this as an update or does it treat it as nothing? I am asking because I wonder if DynamoDb streams will be triggered with this request.
According to the documentation the stream will not be triggered if UpdateItem does not change any data in the item:
If you perform a PutItem or UpdateItem operation that does not change any data in an item, DynamoDB Streams does not write a stream record for that operation.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With