mirror of
https://github.com/apache/datafusion-sqlparser-rs.git
synced 2025-08-28 09:54:15 +00:00
fix: Handle double quotes inside quoted identifiers correctly (#411)
* fix: Handle double quotes inside quoted identifiers correctly This fixes #410 for standard SQL, however I don't know enough about other dialects to know if they handle this differently. May need more extensive testing as well. * refactor: Make quoted identifier parsing a seperate function * test: Check that quoted identifier tokenization works Added `pretty_assertions` so that the `assert_eq!` in the tokenization is readable * test: Check that quoted identifiers work in mysql * chore: cargo clippy
This commit is contained in:
parent
2614576dbf
commit
34fedf311d
6 changed files with 94 additions and 4 deletions
|
@ -178,6 +178,37 @@ fn parse_quote_identifiers() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_quote_identifiers_2() {
|
||||
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('`'),
|
||||
}))],
|
||||
from: vec![],
|
||||
lateral_views: vec![],
|
||||
selection: None,
|
||||
group_by: vec![],
|
||||
cluster_by: vec![],
|
||||
distribute_by: vec![],
|
||||
sort_by: vec![],
|
||||
having: None,
|
||||
})),
|
||||
order_by: vec![],
|
||||
limit: None,
|
||||
offset: None,
|
||||
fetch: None,
|
||||
}))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_unterminated_escape() {
|
||||
let sql = r#"SELECT 'I\'m not fine\'"#;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue