mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix: accept AttributesToGet with Select=SPECIFIC_ATTRIBUTES in Query (#1190)
This commit is contained in:
1 parent
10e28f33c2
commit
70acf49b00
2 files changed
+127
-1
No files matched your search
+120
@@ -293,6 +293,126 @@ class DynamoDbIntegrationTest {
|
||||
.body("Items.size()", equalTo(3));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void queryWithSelectSpecificAttributesAndAttributesToGet() {
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.Query")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "TestTable",
|
||||
"KeyConditionExpression": "pk = :pk",
|
||||
"ExpressionAttributeValues": {
|
||||
":pk": {"S": "user-1"}
|
||||
},
|
||||
"Select": "SPECIFIC_ATTRIBUTES",
|
||||
"AttributesToGet": ["pk", "sk"]
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Count", equalTo(3))
|
||||
.body("Items[0].size()", equalTo(2))
|
||||
.body("Items[0].pk.S", equalTo("user-1"))
|
||||
.body("Items[0].sk.S", equalTo("order-001"))
|
||||
.body("Items[0].name", nullValue())
|
||||
.body("Items[0].age", nullValue())
|
||||
.body("Items[0].total", nullValue())
|
||||
.body("Items[1].size()", equalTo(2))
|
||||
.body("Items[1].pk.S", equalTo("user-1"))
|
||||
.body("Items[1].sk.S", equalTo("order-002"))
|
||||
.body("Items[1].total", nullValue())
|
||||
.body("Items[2].size()", equalTo(2))
|
||||
.body("Items[2].pk.S", equalTo("user-1"))
|
||||
.body("Items[2].sk.S", equalTo("profile"))
|
||||
.body("Items[2].name", nullValue())
|
||||
.body("Items[2].age", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void queryWithSelectSpecificAttributesAndProjectionExpression() {
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.Query")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "TestTable",
|
||||
"KeyConditionExpression": "pk = :pk",
|
||||
"ExpressionAttributeValues": {
|
||||
":pk": {"S": "user-1"}
|
||||
},
|
||||
"Select": "SPECIFIC_ATTRIBUTES",
|
||||
"ProjectionExpression": "pk, sk"
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(200)
|
||||
.body("Count", equalTo(3))
|
||||
.body("Items[0].size()", equalTo(2))
|
||||
.body("Items[0].pk.S", equalTo("user-1"))
|
||||
.body("Items[0].sk.S", equalTo("order-001"))
|
||||
.body("Items[0].name", nullValue())
|
||||
.body("Items[0].age", nullValue())
|
||||
.body("Items[0].total", nullValue());
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void queryWithSelectSpecificAttributesRequiresProjectionParameters() {
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.Query")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "TestTable",
|
||||
"KeyConditionExpression": "pk = :pk",
|
||||
"ExpressionAttributeValues": {
|
||||
":pk": {"S": "user-1"}
|
||||
},
|
||||
"Select": "SPECIFIC_ATTRIBUTES"
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("Select type SPECIFIC_ATTRIBUTES requires the ProjectionExpression to be provided."));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void queryWithProjectionExpressionAndAttributesToGetFails() {
|
||||
given()
|
||||
.header("X-Amz-Target", "DynamoDB_20120810.Query")
|
||||
.contentType(DYNAMODB_CONTENT_TYPE)
|
||||
.body("""
|
||||
{
|
||||
"TableName": "TestTable",
|
||||
"KeyConditionExpression": "pk = :pk",
|
||||
"ExpressionAttributeValues": {
|
||||
":pk": {"S": "user-1"}
|
||||
},
|
||||
"Select": "SPECIFIC_ATTRIBUTES",
|
||||
"ProjectionExpression": "pk, sk",
|
||||
"AttributesToGet": ["pk", "sk"]
|
||||
}
|
||||
""")
|
||||
.when()
|
||||
.post("/")
|
||||
.then()
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("Can not use both expression and non-expression parameters in the same request: "
|
||||
+ "Non-expression parameters: {AttributesToGet} Expression parameters: {ProjectionExpression}"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(10)
|
||||
void queryWithBeginsWith() {
|
||||
|
||||
Reference in new issue
Block a user