Skip to content
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

Fix string escaping #13

Merged
merged 1 commit into from
May 5, 2022
Merged

Fix string escaping #13

merged 1 commit into from
May 5, 2022

Conversation

aljazerzen
Copy link
Contributor

The is a bug in string escaping code.

Reproduction:

fn main() {
    use sqlformat::*;

    let res = format("''some text ending with escaped quote''", &QueryParams::None, FormatOptions::default());
    println!("{res}");
}

prints:

' some text ending with escaped quote ' ''

but should print:

'some text ending with escaped quote'''

It's a small bug in tokenizer::take_till_escaping, which I fixed and added a test to cover this case.

@aljazerzen
Copy link
Contributor Author

PS: we use this crate at PRQL and this is how we found the bug.

Copy link
Owner

@shssoichiro shssoichiro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Much appreciated! (This makes me wonder if the Javascript library this is ported from has the same bug 🤔 )

@shssoichiro shssoichiro merged commit 62c7110 into shssoichiro:master May 5, 2022
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 this pull request may close these issues.

2 participants