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

@ -33,8 +33,6 @@ pub fn parse_insert(input: &str) -> IResult<&str, RawQuerySyntax> {
let (input, values) = parse_values(input)?;
let (input, _) = multispace0(input)?;
let (input, _) = char(')')(input)?;
let (input, _) = multispace0(input)?;
let (input, _) = char(';')(input)?;
Ok((
input,
RawQuerySyntax::Insert(
@ -64,7 +62,7 @@ mod tests {
#[test]
fn test_parse_insert() {
let sql = "INSERT INTO \"MyTable\" (id, data) VALUES(1, \"Text\");";
let sql = "INSERT INTO \"MyTable\" (id, data) VALUES(1, \"Text\")";
let syntax = parse_insert(sql).expect("should parse");
match syntax {
("", RawQuerySyntax::Insert(table_name, insertion_values)) => {
@ -89,7 +87,7 @@ mod tests {
#[test]
fn test_parse_insert_with_spaces() {
let sql =
"INSERT INTO \"MyTable\" ( id, data ) VALUES ( 1, \"Text\" ) ;";
"INSERT INTO \"MyTable\" ( id, data ) VALUES ( 1, \"Text\" )";
let operation = parse_insert(sql).expect("should parse");
match operation {
("", RawQuerySyntax::Insert(table_name, insertion_values)) => {