Fix escaping of trailing quote in quoted identifiers (#505)

* Generalize EscapeSingleQuoteString to arbitrary quote character

* Fix escaping of trailing quote in quoted identifiers

* Add new tests instead of modifying existing tests
This commit is contained in:
Riccardo Azzolini 2022-05-27 12:25:24 +02:00 committed by GitHub
parent cc2559c097
commit d19c6c323c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 18 deletions

View file

@ -325,6 +325,40 @@ fn parse_quote_identifiers_2() {
);
}
#[test]
fn parse_quote_identifiers_3() {
let sql = "SELECT ```quoted identifier```";
assert_eq!(
mysql().verified_stmt(sql),
Statement::Query(Box::new(Query {
with: None,
body: SetExpr::Select(Box::new(Select {
distinct: false,
top: None,
projection: vec![SelectItem::UnnamedExpr(Expr::Identifier(Ident {
value: "`quoted identifier`".into(),
quote_style: Some('`'),
}))],
into: None,
from: vec![],
lateral_views: vec![],
selection: None,
group_by: vec![],
cluster_by: vec![],
distribute_by: vec![],
sort_by: vec![],
having: None,
qualify: None
})),
order_by: vec![],
limit: None,
offset: None,
fetch: None,
lock: None,
}))
);
}
#[test]
fn parse_unterminated_escape() {
let sql = r#"SELECT 'I\'m not fine\'"#;