Skip to content
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,6 @@
{
"type": "bugfix",
"category": "DynamoDB Enhanced Client",
"contributor": "",
"description": "The DynamoDB Enhanced Client now properly sanitizes version attribute names when building conditional expressions for optimistic locking. Version attributes with special characters in their names will now work correctly. See [#3279](https://github.com/aws/aws-sdk-java-v2/issues/3279)"
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

package software.amazon.awssdk.enhanced.dynamodb.extensions;

import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.cleanAttributeName;
import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.isNullAttributeValue;
import static software.amazon.awssdk.enhanced.dynamodb.internal.EnhancedClientUtils.keyRef;

Expand Down Expand Up @@ -58,7 +59,8 @@
@SdkPublicApi
@ThreadSafe
public final class VersionedRecordExtension implements DynamoDbEnhancedClientExtension {
private static final Function<String, String> VERSIONED_RECORD_EXPRESSION_VALUE_KEY_MAPPER = key -> ":old_" + key + "_value";
private static final Function<String, String> VERSIONED_RECORD_EXPRESSION_VALUE_KEY_MAPPER =
key -> ":old_" + cleanAttributeName(key) + "_value";
private static final String CUSTOM_METADATA_KEY = "VersionedRecordExtension:VersionAttribute";
private static final VersionAttribute VERSION_ATTRIBUTE = new VersionAttribute();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public int hashCode() {
.addAttribute(String.class, a -> a.name("_attribute")
.getter(Record::get_attribute)
.setter(Record::set_attribute))
.addAttribute(Integer.class, a -> a.name("_version")
.addAttribute(Integer.class, a -> a.name("_my-:.version")
.getter(Record::get_version)
.setter(Record::set_version)
.tags(versionAttribute()))
Expand Down
Loading