Skip to content

Fix for handling special characters in attribute names with WRITE_IF_… #2100

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

Merged
merged 2 commits into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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