fix: add list_append support to DynamoDB update expressions (#277)

DynamoDbService was not handling the list_append function in update
expressions. This adds the logic to extract both list arguments, resolve
them from expression attributes or item attributes, and merge them into
the DynamoDB list format (with "L" structure).

Includes integration test covering basic list append operation.
This commit is contained in:
Uğur Tafralı authored and GitHub committed 2026-04-08 00:36:06 -05:00
1 parent 1ddc8a32f7
commit b723a9c519
2 files changed
+105

No files matched your search

@@ -961,6 +961,28 @@ public class DynamoDbService {
item.set(attrName, resolved);
}
}
} else if (valuePart.startsWith("list_append(")) {
String[] args = extractFunctionArgs(valuePart);
if (args.length == 2) {
String arg1 = args[0].trim();
String arg2 = args[1].trim();
JsonNode list1 = arg1.startsWith(":") && exprAttrValues != null
? exprAttrValues.get(arg1)
: item.get(resolveAttributeName(arg1, exprAttrNames));
JsonNode list2 = arg2.startsWith(":") && exprAttrValues != null
? exprAttrValues.get(arg2)
: item.get(resolveAttributeName(arg2, exprAttrNames));
if (list1 != null && list2 != null && list1.has("L") && list2.has("L")) {
com.fasterxml.jackson.databind.node.ArrayNode merged =
com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.arrayNode();
list1.get("L").forEach(merged::add);
list2.get("L").forEach(merged::add);
com.fasterxml.jackson.databind.node.ObjectNode result =
com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
result.set("L", merged);
item.set(attrName, result);
}
}
} else if (valuePart.startsWith(":") && exprAttrValues != null) {
JsonNode value = exprAttrValues.get(valuePart);
if (value != null) {