mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(dynamodb): name the partition key in a PartiQL INSERT's own condition (#7381)
This commit is contained in:
1 parent
eaa553cf7a
commit
4933126314
2 files changed
+95
-3
No files matched your search
+6
-3
@@ -550,10 +550,11 @@ class DynamoDbPartiQLHandler {
|
||||
ObjectNode item = mapper.createObjectNode();
|
||||
stmt.item().forEach((k, v) -> item.set(k, toTypedNode(v)));
|
||||
|
||||
ExprAttrNameBuilder ean = new ExprAttrNameBuilder();
|
||||
String keyIsNew = "attribute_not_exists(" + ean.alias(pkName) + ")";
|
||||
JsonNode previousItem;
|
||||
try {
|
||||
previousItem = service.putItem(stmt.table(), item, "attribute_not_exists(" + pkName + ")",
|
||||
null, null, region, "NONE");
|
||||
previousItem = service.putItem(stmt.table(), item, keyIsNew, ean.toNode(mapper), null, region, "NONE");
|
||||
} catch (ConditionalCheckFailedException e) {
|
||||
throw new AwsException("DuplicateItemException", "Duplicate primary key exists in table", 400);
|
||||
}
|
||||
@@ -674,7 +675,9 @@ class DynamoDbPartiQLHandler {
|
||||
ObjectNode put = mapper.createObjectNode();
|
||||
put.put("TableName", ins.table());
|
||||
put.set("Item", item);
|
||||
put.put("ConditionExpression", "attribute_not_exists(" + pkName + ")");
|
||||
ExprAttrNameBuilder ean = new ExprAttrNameBuilder();
|
||||
put.put("ConditionExpression", "attribute_not_exists(" + ean.alias(pkName) + ")");
|
||||
put.set("ExpressionAttributeNames", ean.toNode(mapper));
|
||||
txItem.set("Put", put);
|
||||
}
|
||||
case Stmt.Update upd -> {
|
||||
|
||||
Reference in new issue
Block a user