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

@ -22,8 +22,6 @@ pub fn parse_create(input: &str) -> IResult<&str, RawQuerySyntax> {
let (input, column_definitions) = parse_column_definitions(input)?;
let (input, _) = char(')')(input)?;
let (input, _) = multispace0(input)?;
let (input, _) = char(';')(input)?;
let schema = RawTableSchema {
table_name: table_name.to_string(),
columns: column_definitions,
@ -66,32 +64,32 @@ mod tests {
#[test]
fn test_parse_create_no_spaces() {
parse_create("CREATE TABLE \"Table1\"(id UUID ,column1 INT);").expect("should parse");
parse_create("CREATE TABLE \"Table1\"(id UUID ,column1 INT)").expect("should parse");
}
#[test]
fn test_parse_create_primary_key() {
parse_create("CREATE TABLE \"Table1\"(id UUID PRIMARY KEY,column1 INT);")
parse_create("CREATE TABLE \"Table1\"(id UUID PRIMARY KEY,column1 INT)")
.expect("should parse");
}
#[test]
fn test_parse_create_no_quotes_table_name() {
parse_create("CREATE TABLE Table1(id UUID PRIMARY KEY,column1 INT);")
parse_create("CREATE TABLE Table1(id UUID PRIMARY KEY,column1 INT)")
.expect("should parse");
}
#[test]
fn test_parse_create_primary_key_with_spaces() {
parse_create(
"CREATE TABLE \"Table1\" ( id UUID PRIMARY KEY , column1 INT ) ;",
"CREATE TABLE \"Table1\" ( id UUID PRIMARY KEY , column1 INT )",
)
.expect("should parse");
}
#[test]
fn test_parse_create() {
let (_, create) = parse_create("CREATE TABLE \"Table1\"( id UUID , column1 INT );")
let (_, create) = parse_create("CREATE TABLE \"Table1\"( id UUID , column1 INT )")
.expect("should parse");
assert!(matches!(create, RawQuerySyntax::CreateTable(_)));
match create {