mirror of
https://github.com/floci-io/floci.git
synced 2026-12-01 01:12:48 -05:00
fix(dynamodb): refuse a PartiQL statement that is one term as DynamoDB does (#7068)
This commit is contained in:
1 parent
dcf8ec7430
commit
a2e12ee004
3 files changed
+194
-2
No files matched your search
+20
@@ -556,6 +556,26 @@ class DynamoDbPartiQLIntegrationTest {
|
||||
equalTo("Statement wasn't well formed, can't be processed: Unexpected token after expression"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@Order(27)
|
||||
void aStatementThatIsOneTermIsRefusedByItsKind() {
|
||||
statement("x IS INT4")
|
||||
.statusCode(400)
|
||||
.body("__type", equalTo("ValidationException"))
|
||||
.body("message", equalTo("Unsupported operation: IsType"));
|
||||
request("DynamoDB_20120810.ExecuteTransaction", """
|
||||
{"TransactStatements":[{"Statement":"?"}]}
|
||||
""")
|
||||
.statusCode(400)
|
||||
.body("message", equalTo("Validation failed in TransactStatements[0]: Unsupported operation: Parameter"));
|
||||
request("DynamoDB_20120810.BatchExecuteStatement", """
|
||||
{"Statements":[{"Statement":"x.y IS DOUBLE PRECISION"}]}
|
||||
""")
|
||||
.statusCode(200)
|
||||
.body("Responses[0].Error.Code", equalTo("ValidationError"))
|
||||
.body("Responses[0].Error.Message", equalTo("Unsupported operation: IsType"));
|
||||
}
|
||||
|
||||
private static void putItem(String pk, String attributes) {
|
||||
request("DynamoDB_20120810.PutItem", """
|
||||
{"TableName":"%s","Item":{"pk":{"S":"%s"},%s}}
|
||||
|
||||
+47
@@ -553,6 +553,53 @@ class DynamoDbPartiQLParserTest {
|
||||
assertEquals(expected, refusal(statement));
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@CsvSource(delimiter = '|', quoteCharacter = '`', textBlock = """
|
||||
x IS INT4 | Unsupported operation: IsType
|
||||
x is character varying; | Unsupported operation: IsType
|
||||
((x) IS NULL) IS TIME WITH TIME ZONE | Unsupported operation: IsType
|
||||
"size" | Unsupported operation: Id
|
||||
begins_with | Unsupported operation: Id
|
||||
x.y[0] | Unsupported operation: Path
|
||||
(x).y | Unsupported operation: Path
|
||||
'a'[0] | Unsupported operation: Path
|
||||
?.x | Unsupported operation: Path
|
||||
<<1>>[0] | Unsupported operation: Path
|
||||
(-1).x | Unsupported operation: Path
|
||||
(x IS NOT NULL).y | Unsupported operation: Path
|
||||
- 1 | Unsupported operation: Lit
|
||||
- + 1 | Unsupported operation: Lit
|
||||
-((1)) | Unsupported operation: Lit
|
||||
1e126 | Unsupported operation: Lit
|
||||
NULL | Unsupported operation: Lit
|
||||
MISSING | Unsupported operation: Missing
|
||||
? | Unsupported operation: Parameter
|
||||
[1e126] | Unsupported operation: List
|
||||
{} | Unsupported operation: Struct
|
||||
<<1, 1>> | Unsupported operation: Bag
|
||||
x IS NOT NULL IS NULL | Unsupported operation: IsType
|
||||
-x IS NULL | Unsupported operation: IsType
|
||||
-(1) IS NULL | Unsupported operation: IsType
|
||||
(x).y IS NULL | Unsupported operation: IsType
|
||||
x IS FOO | NWF Expected type name
|
||||
x IS NOT | NWF Expected type name
|
||||
x IS INT4(1) | NWF is type argument integer4 must have arity of 0..0
|
||||
x IS INT4 y | NWF Unexpected token after expression
|
||||
x AS y | NWF Unexpected token after expression
|
||||
x IS NOT NULL y | NWF Unexpected token after expression
|
||||
-x y | NWF Unexpected token after expression
|
||||
x IS NULL.y | NWF Unexpected token after expression
|
||||
(x) (1) | NWF Unexpected token after expression
|
||||
() | NWF Unexpected term
|
||||
(WHERE | NWF Unexpected keyword
|
||||
((x) | NWF Expected RIGHT_PAREN
|
||||
(x IS NOT NULL | NWF Expected RIGHT_PAREN
|
||||
SLECT * FROM "t" WHERE pk = 'a' | NWF Expected data manipulation
|
||||
""")
|
||||
void refusesAStatementThatIsOneTermByItsKind(String statement, String message) {
|
||||
assertEquals(message.replace("NWF ", "Statement wasn't well formed, can't be processed: "), refusal(statement));
|
||||
}
|
||||
|
||||
private static String refusal(String statement) {
|
||||
return assertThrows(AwsException.class, () -> DynamoDbPartiQLParser.parse(statement, List.of())).getMessage();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user