Skip to content

Commit 356c3c5

Browse files
committed
DynamoDb enhanced client: support UpdateExpressions in single-request update
1 parent 248dbb4 commit 356c3c5

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

services-custom/dynamodb-enhanced/src/main/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionConverter.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ private UpdateExpressionConverter() {
7373
* of whether it represents an update expression, conditional expression or another type of expression, since once
7474
* the string is generated that update expression is the final format accepted by DDB.
7575
*
76-
* @return an Expression representing the concatenation of all actions in this UpdateExpression
76+
* @param expression the UpdateExpression to convert
77+
*
78+
* @return an Expression representing the concatenation of all actions in this UpdateExpression, or null if the expression
79+
* is null or empty
7780
*/
7881
public static Expression toExpression(UpdateExpression expression) {
7982
if (expression == null || expression.isEmpty()) {
@@ -91,8 +94,8 @@ public static Expression toExpression(UpdateExpression expression) {
9194
}
9295

9396
/**
94-
* Attempts to find the list of attributes associated with update actions for the supplied {@link UpdateExpression} by
95-
* looking at the combined collection of paths and ExpressionName values. Because attribute names can be composed of nested
97+
* Attempts to find the list of attribute names that will be updated for the supplied {@link UpdateExpression} by looking at
98+
* the combined collection of paths and ExpressionName values. Because attribute names can be composed from nested
9699
* attribute references and list references, the leftmost part will be returned if composition is detected.
97100
* <p>
98101
* Examples: The expression contains a {@link DeleteAction} with a path value of 'MyAttribute[1]'; the list returned

services-custom/dynamodb-enhanced/src/test/java/software/amazon/awssdk/enhanced/dynamodb/internal/update/UpdateExpressionConverterTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ class UpdateExpressionConverterTest {
4747
private static final String VALUE_TOKEN = ":PRE_";
4848

4949
@Test
50-
void convert_emptyExpression() {
50+
void convert_nullUpdateExpression_returnsNullExpression() {
51+
UpdateExpression updateExpression = null;
52+
Expression expression = UpdateExpressionConverter.toExpression(updateExpression);
53+
54+
assertThat(expression).isNull();
55+
}
56+
57+
@Test
58+
void convert_emptyUpdateExpression_returnsNullExpression() {
5159
UpdateExpression updateExpression = UpdateExpression.builder().build();
5260
Expression expression = UpdateExpressionConverter.toExpression(updateExpression);
5361

0 commit comments

Comments
 (0)