mirror of
https://github.com/floci-io/floci.git
synced 2026-11-24 06:20:24 -05:00
fix(dynamodb): resolve nested document paths in ADD and DELETE update actions (#1908)
This commit is contained in:
3 files changed
+266
-7
No files matched your search
@@ -1722,15 +1722,15 @@ public class DynamoDbService {
|
||||
String[] parts = clause.split("\\s+", 3);
|
||||
if (parts.length < 2) break;
|
||||
|
||||
String attrName = resolveAttributeName(parts[0], exprAttrNames);
|
||||
String attrPath = parts[0];
|
||||
String valuePlaceholder = parts[1].replaceAll(",.*", "").trim();
|
||||
|
||||
if (valuePlaceholder.startsWith(":") && exprAttrValues != null) {
|
||||
JsonNode addValue = exprAttrValues.get(valuePlaceholder);
|
||||
if (addValue != null) {
|
||||
JsonNode existingValue = item.get(attrName);
|
||||
JsonNode existingValue = getValueAtPath(item, attrPath, exprAttrNames);
|
||||
JsonNode newValue = applyAddOperation(existingValue, addValue);
|
||||
item.set(attrName, newValue);
|
||||
setValueAtPath(item, attrPath, newValue, exprAttrNames);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1833,19 +1833,19 @@ public class DynamoDbService {
|
||||
String[] parts = clause.split("\\s+", 3);
|
||||
if (parts.length < 2) break;
|
||||
|
||||
String attrName = resolveAttributeName(parts[0], exprAttrNames);
|
||||
String attrPath = parts[0];
|
||||
String valuePlaceholder = parts[1].replaceAll(",.*", "").trim();
|
||||
|
||||
if (valuePlaceholder.startsWith(":") && exprAttrValues != null) {
|
||||
JsonNode deleteValue = exprAttrValues.get(valuePlaceholder);
|
||||
if (deleteValue != null) {
|
||||
JsonNode existingValue = item.get(attrName);
|
||||
JsonNode existingValue = getValueAtPath(item, attrPath, exprAttrNames);
|
||||
if (existingValue != null) {
|
||||
JsonNode newValue = applyDeleteOperation(existingValue, deleteValue);
|
||||
if (newValue == null) {
|
||||
item.remove(attrName);
|
||||
removeValueAtPath(item, attrPath, exprAttrNames);
|
||||
} else {
|
||||
item.set(attrName, newValue);
|
||||
setValueAtPath(item, attrPath, newValue, exprAttrNames);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user