Skip to content

Commit

Permalink
Fix multiple field mappings conflict with each other, replacing own v…
Browse files Browse the repository at this point in the history
…alue
  • Loading branch information
matusfaro committed Nov 30, 2024
1 parent 5c97226 commit cb9eec5
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,7 @@ public P delete(String fieldName, Object object) {

@Override
public String fieldMapping(String fieldName) {
String mappedName = "#" + sanitizeFieldMapping(fieldName);
nameMap.put(mappedName, fieldName);
return mappedName;
return fieldMapping(fieldName, fieldName);
}

@Override
Expand All @@ -225,6 +223,9 @@ public String fieldMapping(ImmutableList<String> fieldPath) {
@Override
public String fieldMapping(String fieldName, String fieldValue) {
String mappedName = "#" + sanitizeFieldMapping(fieldName);
while (nameMap.containsKey(mappedName) && !nameMap.get(mappedName).equals(fieldName)) {
mappedName = mappedName + "_";
}
nameMap.put(mappedName, fieldValue);
return mappedName;
}
Expand All @@ -238,6 +239,9 @@ public String valueMapping(String fieldName, Object object) {
public String constantMapping(String name, Object object) {
String mappedName = ":" + sanitizeFieldMapping(name);
AttributeValue value = schema.toAttrValue(object);
while (valMap.containsKey(mappedName) && !valMap.get(mappedName).equals(value)) {
mappedName = mappedName + "_";
}
valMap.put(mappedName, value);
return mappedName;
}
Expand Down

0 comments on commit cb9eec5

Please sign in to comment.