mirror of
https://github.com/floci-io/floci.git
synced 2026-11-27 07:39:24 -05:00
fix(dynamodb): use the AWS wording when Query or Scan rejects AttributesToGet with a Select (#5599)
* fix(dynamodb): use the AWS wording when Query or Scan rejects AttributesToGet with a Select * refactor(dynamodb): share the Select conflict check for ProjectionExpression and AttributesToGet
This commit is contained in:
1 parent
ddc0e0257b
commit
dd0f40fcbb
2 files changed
+34
-8
No files matched your search
+10
-8
@@ -55,18 +55,12 @@ final class DynamoDbAccessPathValidator {
|
||||
static void validateSelection(TableDefinition table, DynamoDbAccessPath accessPath,
|
||||
String select, String projectionExpression,
|
||||
JsonNode attributesToGet, JsonNode expressionAttributeNames) {
|
||||
if (projectionExpression != null && select != null && !"SPECIFIC_ATTRIBUTES".equals(select)) {
|
||||
throw validationException("1 validation error detected: "
|
||||
+ "Cannot specify the ProjectionExpression when choosing to get "
|
||||
+ ("COUNT".equals(select) ? "only the Count" : select));
|
||||
}
|
||||
rejectWithSelect("ProjectionExpression", projectionExpression != null, select);
|
||||
rejectWithSelect("AttributesToGet", attributesToGet != null, select);
|
||||
if ("ALL_PROJECTED_ATTRIBUTES".equals(select) && !accessPath.isIndex()) {
|
||||
throw validationException("1 validation error detected: "
|
||||
+ "ALL_PROJECTED_ATTRIBUTES can be used only when Querying using an IndexName");
|
||||
}
|
||||
if (attributesToGet != null && select != null && !"SPECIFIC_ATTRIBUTES".equals(select)) {
|
||||
throw validationException("Cannot use both Select and AttributesToGet unless Select is SPECIFIC_ATTRIBUTES");
|
||||
}
|
||||
if (!accessPath.isGlobalSecondaryIndex() || "ALL".equals(accessPath.projectionType())) {
|
||||
return;
|
||||
}
|
||||
@@ -93,6 +87,14 @@ final class DynamoDbAccessPathValidator {
|
||||
}
|
||||
}
|
||||
|
||||
private static void rejectWithSelect(String parameter, boolean present, String select) {
|
||||
if (present && select != null && !"SPECIFIC_ATTRIBUTES".equals(select)) {
|
||||
throw validationException("1 validation error detected: "
|
||||
+ "Cannot specify the " + parameter + " when choosing to get "
|
||||
+ ("COUNT".equals(select) ? "only the Count" : select));
|
||||
}
|
||||
}
|
||||
|
||||
private static String validateKeyConditionExpression(TableDefinition table,
|
||||
DynamoDbAccessPath accessPath,
|
||||
String expression, JsonNode names,
|
||||
|
||||
Reference in new issue
Block a user