Skip to content

Commit

Permalink
Fix for handling special characters in attribute names with WRITE_IF_…
Browse files Browse the repository at this point in the history
…NOT_EXISTS update behavior
  • Loading branch information
bmaizels committed Oct 19, 2020
1 parent fc6860c commit 5061593
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"type": "bugfix",
"category": "Amazon DynamoDB Enhanced Client",
"description": "Fix for handling special characters in attribute names with WRITE_IF_NOT_EXISTS update behavior"
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ public class UpdateItemOperation<T>
key -> "#AMZN_MAPPED_" + EnhancedClientUtils.cleanAttributeName(key);

private static final Function<String, String> CONDITIONAL_UPDATE_MAPPER =
key -> "if_not_exists(" + key + ", " + EXPRESSION_VALUE_KEY_MAPPER.apply(key) + ")";
key -> "if_not_exists(" + EXPRESSION_KEY_MAPPER.apply(key) + ", " +
EXPRESSION_VALUE_KEY_MAPPER.apply(key) + ")";

private final UpdateItemEnhancedRequest<T> request;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.time.Instant;
import software.amazon.awssdk.enhanced.dynamodb.extensions.annotations.DynamoDbVersionAttribute;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbAttribute;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbBean;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbPartitionKey;
import software.amazon.awssdk.enhanced.dynamodb.mapper.annotations.DynamoDbUpdateBehavior;
Expand All @@ -41,6 +42,7 @@ public void setId(String id) {
}

@DynamoDbUpdateBehavior(WRITE_IF_NOT_EXISTS)
@DynamoDbAttribute("created-on") // Forces a test on attribute name cleaning
public Instant getCreatedOn() {
return createdOn;
}
Expand Down

0 comments on commit 5061593

Please sign in to comment.