Skip to content

MySql dialect doesn't handle slash-escaped single quotes #362

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

Open
WesleyAC opened this issue Oct 16, 2021 · 2 comments
Open

MySql dialect doesn't handle slash-escaped single quotes #362

WesleyAC opened this issue Oct 16, 2021 · 2 comments

Comments

@WesleyAC
Copy link

WesleyAC commented Oct 16, 2021

The following fails to parse:

fn main() {
    println!("{:?}",
        sqlparser::parser::Parser::parse_sql(
            &sqlparser::dialect::MySqlDialect {},
            r#"INSERT INTO `example` (`col`) VALUES ('foo \'bar\' baz');"#
        )
    );
}

Instead returning:

Err(ParserError("Expected ), found: bar"))

But I believe it shouldn't — mysqldump generates SQL that is escaped like this, and the docs explicitly mention this as a valid escaping (see Table 9.1).

This is, according to this doc a difference between ANSI SQL and MySQL, but unfortunately this needs to be fixed in the tokenizer, which AFAICT the dialect system doesn't have a way to hook into?

@WesleyAC WesleyAC changed the title MySql dialect doesn't handle escaped single quotes MySql dialect doesn't handle slash-escaped single quotes Oct 16, 2021
@houqp
Copy link
Member

houqp commented Oct 16, 2021

looks like a bug to me and I think you are right that the current dialect trait needs to be extended to support this use-case.

@sanxiyn
Copy link
Contributor

sanxiyn commented Aug 17, 2022

This seems fixed. If so, please close.

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

No branches or pull requests

3 participants