Skip to content
Snippets Groups Projects
Verified Commit 433c6f56 authored by Denis Smirnov's avatar Denis Smirnov
Browse files

feat(grammar): add ascii non-letter symbols to the values

parent 89ea4b24
No related branches found
No related tags found
1 merge request!1414sbroad import
......@@ -418,3 +418,22 @@ fn front_params3() {
assert_eq!(sql_to_sql(pattern, &params, &no_transform), expected);
}
// check symbols in values (grammar)
#[test]
fn front_params4() {
let pattern = r#"SELECT "id" FROM "test_space"
WHERE "FIRST_NAME" = '''±!@#$%^&*()_+=-\/><";:,.`~'"#;
let params = vec![Value::from(r#"''±!@#$%^&*()_+=-\/><";:,.`~"#)];
let expected = PatternWithParams::new(
format!(
"{} {}",
r#"SELECT "test_space"."id" as "id" FROM "test_space""#,
r#"WHERE ("test_space"."FIRST_NAME") = (?)"#,
),
params,
);
assert_eq!(sql_to_sql(pattern, &vec![], &no_transform), expected);
}
......@@ -13,7 +13,7 @@ Query = _{ UnionAll | Select | Values | Insert }
Reference = { (ScanName ~ "." ~ ColumnName) | ColumnName }
ColumnName = @{ Name }
ScanName = @{ Name }
Name = @{ String | ("\"" ~ String ~ "\"") }
Name = @{ NameString | ("\"" ~ NameString ~ "\"") }
Asterisk = @{ "*" }
Selection = { Expr+ }
Scan = { (SubQuery | Table) ~ (^"as" ~ ScanName)? }
......@@ -59,8 +59,20 @@ Expr = _{ Or | And | Cmp | Primary | Parentheses }
OrLeft = _{ AndRight }
OrRight = _{ Or | OrLeft }
String = @{ !(WHITESPACE* ~ Keyword ~ WHITESPACE) ~ ('А' .. 'Я' | 'а' .. 'я' | 'A' .. 'Z' | 'a'..'z' | "-" | "_" | ASCII_DIGIT)+ }
Keyword = { ^"union" | ^"where" }
NameString = @{ !(WHITESPACE* ~ Keyword ~ WHITESPACE) ~ ('А' .. 'Я' | 'а' .. 'я' | 'A' .. 'Z' | 'a'..'z' | "-" | "_" | ASCII_DIGIT)+ }
String = @{ !(WHITESPACE* ~ Keyword ~ WHITESPACE) ~ (Character | ("'" ~ "'") | "\"")+ }
Keyword = { ^"union" | ^"where" }
Character = _{ ASCII_ALPHANUMERIC | 'А' .. 'Я' | 'а' .. 'я' | Other | Punctuation | SYMBOL }
Punctuation = _{
CONNECTOR_PUNCTUATION
| DASH_PUNCTUATION
| OPEN_PUNCTUATION
| CLOSE_PUNCTUATION
| INITIAL_PUNCTUATION
| "." | "?" | "!" | ":" | ";" | ","
}
Other = _{ "\\" | "/" | "@" | "%" | "&" | "*" | "#" }
Value = _{ Parameter | Row | True | False | Null | Decimal | Double | Unsigned | Integer | SingleQuotedString }
True = @{ ^"true" }
......
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