Skip to content
Snippets Groups Projects
Commit bd91b9b7 authored by Arseniy Volynets's avatar Arseniy Volynets
Browse files

fix(grammar): fix condition and selection grammar

parent dd335893
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -141,6 +141,7 @@ fn traversal() {
assert_eq!(None, dft_post.next());
}
#[test]
fn invalid_query() {
let query = r#"select a frAm t"#;
......@@ -157,3 +158,21 @@ fn invalid_query() {
format!("{}", ast),
);
}
#[test]
fn invalid_condition() {
let query = r#"SELECT "identification_number", "product_code" FROM "test_space" WHERE
"identification_number" = 1 "product_code" = 2"#;
let ast = AbstractSyntaxTree::new(query).unwrap_err();
assert_eq!(
format!(
r#"Parsing error: --> 2:33
|
2 | "identification_number" = 1 "product_code" = 2
| ^---
|
= expected EOI"#,
),
format!("{}", ast),
)
}
......@@ -18,11 +18,11 @@ Query = _{ Except | UnionAll | Select | Values | Insert }
ScanName = @{ Name }
Name = @{ NameString | ("\"" ~ NameString ~ "\"") }
Asterisk = @{ "*" }
Selection = { Expr+ }
Selection = { Expr }
Scan = { (SubQuery | Table) ~ (^"as" ~ ScanName)? }
Table = @{ Name }
InnerJoin = { Scan }
Condition = { Expr+ }
Condition = { Expr }
UnionAll = { (SubQuery | Select) ~ ^"union" ~ ^"all" ~ (SubQuery | Select) }
Except = { (SubQuery | Select) ~ ((^"except" ~ ^"distinct") | ^"except") ~ (SubQuery | Select) }
SubQuery = { "(" ~ (Except | UnionAll | Select | Values) ~ ")" }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment