mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
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:
1 parent
1ddc8a32f7
commit
b723a9c519
2 files changed
+105
No files matched your search
+83
@@ -748,6 +748,89 @@ class DynamoDbIntegrationTest {
|
||||
.body("__type", equalTo("ResourceNotFoundException"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(27)
|
||||
void updateItemListAppend() {
|
||||
// Create a table for this test
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.CreateTable")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "ListAppendTable",
|
||||
"KeySchema": [{"AttributeName": "pk", "KeyType": "HASH"}],
|
||||
"AttributeDefinitions": [{"AttributeName": "pk", "AttributeType": "S"}],
|
||||
"BillingMode": "PAY_PER_REQUEST"
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Put item with initial list
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.PutItem")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "ListAppendTable",
|
||||
"Item": {"pk": {"S": "k1"}, "items": {"L": [{"S": "a"}]}}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Append to list
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.UpdateItem")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "ListAppendTable",
|
||||
"Key": {"pk": {"S": "k1"}},
|
||||
"UpdateExpression": "SET items = list_append(items, :val)",
|
||||
"ExpressionAttributeValues": {":val": {"L": [{"S": "b"}]}}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
|
||||
// Verify both elements present
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.GetItem")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "ListAppendTable",
|
||||
"Key": {"pk": {"S": "k1"}}
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Item.items.L.size()", equalTo(2))
|
||||
.body("Item.items.L[0].S", equalTo("a"))
|
||||
.body("Item.items.L[1].S", equalTo("b"));
|
||||
|
||||
// Cleanup
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.DeleteTable")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{"TableName": "ListAppendTable"}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200);
|
||||
}
|
||||
|
||||
@Test
|
||||
void unsupportedOperation() {
|
||||
given()
|
||||
|
||||
Reference in new issue
Block a user