Skip to content

Quoted identifiers do not handle escaped quotes #410

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Marwes opened this issue Feb 4, 2022 · 0 comments · Fixed by #411
Closed

Quoted identifiers do not handle escaped quotes #410

Marwes opened this issue Feb 4, 2022 · 0 comments · Fixed by #411

Comments

@Marwes
Copy link
Contributor

Marwes commented Feb 4, 2022

Looking at the code https://github.com/sqlparser-rs/sqlparser-rs/blob/ea0eb1be617635b29d49d712be22a9a568d02366/src/tokenizer.rs#L417-L430 and writing a naive test it doesn't seem like quoted identifiers "quoted "" identifier" handle escaped quotes ("") in anyway. Unless I am missing something I'd be happy to make a PR to implement these.

https://jakewheat.github.io/sql-overview/sql-2016-foundation-grammar.html#delimited-identifier

#[test]
fn parse_quoted_identifier() {
    pg_and_generic().verified_stmt(r#"SELECT "quoted "" ident""#);
}

---- parse_quoted_identifier stdout ----
thread 'parse_quoted_identifier' panicked at 'assertion failed: `(left == right)`
  left: `"SELECT \"quoted \"\" ident\""`,
 right: `"SELECT \"quoted \" AS \" ident\""`', src/test_utils.rs:95:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Marwes pushed a commit to Marwes/sqlparser-rs that referenced this issue Feb 4, 2022
This fixes apache#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.
Marwes pushed a commit to Marwes/sqlparser-rs that referenced this issue Feb 4, 2022
This fixes apache#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.
@alamb alamb closed this as completed in #411 Feb 7, 2022
alamb pushed a commit that referenced this issue Feb 7, 2022
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant