mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(dynamodb): check the Scan segment pairing after the Select checks (#5857)
* fix(dynamodb): check the Scan segment pairing after the Select checks * fix(dynamodb): check the Scan Select conflicts before the segment pairing
This commit is contained in:
1 parent
2a012cf9a4
commit
5b12c620aa
4 files changed
+72
-29
No files matched your search
+10
-10
@@ -327,27 +327,27 @@ class DynamoDbAccessPathValidatorTest {
|
||||
ObjectNode names = mapper.createObjectNode();
|
||||
names.put("#summary", "summary");
|
||||
|
||||
assertDoesNotThrow(() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
assertDoesNotThrow(() -> DynamoDbAccessPathValidator.validateGsiProjection(
|
||||
table, gsiPath, "SPECIFIC_ATTRIBUTES", "pk, status, #summary",
|
||||
null, names));
|
||||
AwsException projectionError = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
() -> DynamoDbAccessPathValidator.validateGsiProjection(
|
||||
table, gsiPath, "SPECIFIC_ATTRIBUTES", "zeta, details",
|
||||
null, null));
|
||||
assertEquals("One or more parameter values were invalid: Global secondary index "
|
||||
+ "status-index does not project details, zeta", projectionError.getMessage());
|
||||
assertThrows(AwsException.class, () -> DynamoDbAccessPathValidator.validateSelection(
|
||||
assertThrows(AwsException.class, () -> DynamoDbAccessPathValidator.validateGsiProjection(
|
||||
table, gsiPath, "ALL_ATTRIBUTES", null, null, null));
|
||||
assertDoesNotThrow(() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
assertDoesNotThrow(() -> DynamoDbAccessPathValidator.validateGsiProjection(
|
||||
table, lsiPath, "ALL_ATTRIBUTES", null, null, null));
|
||||
}
|
||||
|
||||
@Test
|
||||
void rejectsTableAllProjectedAttributesAndInvalidSelectProjectionCombination() {
|
||||
assertThrows(AwsException.class, () -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_PROJECTED_ATTRIBUTES", null, null, null));
|
||||
"ALL_PROJECTED_ATTRIBUTES", null, null, null));
|
||||
assertThrows(AwsException.class, () -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "COUNT", "pk", null, null));
|
||||
"COUNT", null, "pk", null));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -391,14 +391,14 @@ class DynamoDbAccessPathValidatorTest {
|
||||
void namesTheSelectValueWhenRejectingAProjectionExpression() {
|
||||
AwsException allAttributes = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_ATTRIBUTES", "sk", null, null));
|
||||
"ALL_ATTRIBUTES", null, "sk", null));
|
||||
assertEquals("1 validation error detected: "
|
||||
+ "Cannot specify the ProjectionExpression when choosing to get ALL_ATTRIBUTES",
|
||||
allAttributes.getMessage());
|
||||
|
||||
AwsException count = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "COUNT", "sk", null, null));
|
||||
"COUNT", null, "sk", null));
|
||||
assertEquals("1 validation error detected: "
|
||||
+ "Cannot specify the ProjectionExpression when choosing to get only the Count",
|
||||
count.getMessage());
|
||||
@@ -408,14 +408,14 @@ class DynamoDbAccessPathValidatorTest {
|
||||
void reportsTheProjectionExpressionConflictBeforeTheMissingIndex() {
|
||||
AwsException both = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_PROJECTED_ATTRIBUTES", "sk", null, null));
|
||||
"ALL_PROJECTED_ATTRIBUTES", null, "sk", null));
|
||||
assertEquals("1 validation error detected: "
|
||||
+ "Cannot specify the ProjectionExpression when choosing to get ALL_PROJECTED_ATTRIBUTES",
|
||||
both.getMessage());
|
||||
|
||||
AwsException indexOnly = assertThrows(AwsException.class,
|
||||
() -> DynamoDbAccessPathValidator.validateSelection(
|
||||
table, tablePath, "ALL_PROJECTED_ATTRIBUTES", null, null, null));
|
||||
"ALL_PROJECTED_ATTRIBUTES", null, null, null));
|
||||
assertEquals("1 validation error detected: "
|
||||
+ "ALL_PROJECTED_ATTRIBUTES can be used only when Querying using an IndexName",
|
||||
indexOnly.getMessage());
|
||||
|
||||
+37
@@ -1282,6 +1282,43 @@ class NativeDynamoDbJsonHandlerTest {
|
||||
+ "Member must have value greater than or equal to 1", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanReportsTheMissingProjectionBeforeTheSegmentPairing() {
|
||||
AwsException ex = expectValidationException("Scan", json("""
|
||||
{"TableName": "Users", "Select": "SPECIFIC_ATTRIBUTES", "Segment": 5, "TotalSegments": 5}
|
||||
"""));
|
||||
assertEquals("1 validation error detected: Must specify the AttributesToGet or ProjectionExpression "
|
||||
+ "when choosing to get SPECIFIC_ATTRIBUTES", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanReportsAnUnknownSelectBeforeAMissingTotalSegments() {
|
||||
AwsException ex = expectValidationException("Scan", json("""
|
||||
{"TableName": "Users", "Select": "BOGUS", "Segment": 1}
|
||||
"""));
|
||||
assertEquals("1 validation error detected: Value 'BOGUS' at 'select' failed to satisfy constraint: "
|
||||
+ "Member must satisfy enum value set: "
|
||||
+ "[SPECIFIC_ATTRIBUTES, COUNT, ALL_ATTRIBUTES, ALL_PROJECTED_ATTRIBUTES]", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanReportsACountProjectionBeforeTheSegmentPairingOnAMissingTable() {
|
||||
AwsException ex = expectValidationException("Scan", json("""
|
||||
{"TableName": "Missing", "Select": "COUNT", "ProjectionExpression": "a", "Segment": 1}
|
||||
"""));
|
||||
assertEquals("1 validation error detected: "
|
||||
+ "Cannot specify the ProjectionExpression when choosing to get only the Count", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanReportsAllProjectedWithoutAnIndexBeforeAMissingSegment() {
|
||||
AwsException ex = expectValidationException("Scan", json("""
|
||||
{"TableName": "Missing", "Select": "ALL_PROJECTED_ATTRIBUTES", "TotalSegments": 2}
|
||||
"""));
|
||||
assertEquals("1 validation error detected: "
|
||||
+ "ALL_PROJECTED_ATTRIBUTES can be used only when Querying using an IndexName", ex.getMessage());
|
||||
}
|
||||
|
||||
@Test
|
||||
void scanAcceptsSegmentsAtTheBounds() throws Exception {
|
||||
createUsersTable("eu-west-1");
|
||||
|
||||
Reference in new issue
Block a user