Resolve TODOs in parsing

Return error for queries containing non-ASCII characters

Allow underscores in identifiers

Add a delete statement test with spaces

Remove trailing spaces and semicolons from tests and parsers

Complete the multiple statement parser TODO
This commit is contained in:
Maxim Svistunov 2024-02-04 13:32:55 +01:00
parent 5d040f15f5
commit de8c6164cf
7 changed files with 89 additions and 38 deletions

View file

@ -15,8 +15,6 @@ pub fn parse_delete(input: &str) -> IResult<&str, RawQuerySyntax> {
let (input, table_name) = parse_table_name(input)?;
let (input, _) = multispace0(input)?;
let (input, condition) = parse_condition(input)?;
let (input, _) = multispace0(input)?;
let (input, _) = char(';')(input)?;
Ok((
input,
RawQuerySyntax::Delete(table_name.to_string(), condition),
@ -31,9 +29,14 @@ mod tests {
#[test]
fn test_parse_delete() {
let (_, operation) =
parse_delete("DELETE FROM \"T1\" WHERE id = 1 ;").expect("should parse");
parse_delete("DELETE FROM \"T1\" WHERE id = 1").expect("should parse");
assert!(matches!(operation, RawQuerySyntax::Delete(_, _)))
}
// TODO: add test with condition
#[test]
fn test_parse_delete_with_spaces() {
let (_, operation) =
parse_delete("DELETE FROM T1 WHERE id = 1").expect("should parse");
assert!(matches!(operation, RawQuerySyntax::Delete(_, _)))
}
}