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

Parsing bug in string literal ')\'');a' #780

Open
judson-firebolt opened this issue Jul 11, 2024 · 1 comment
Open

Parsing bug in string literal ')\'');a' #780

judson-firebolt opened this issue Jul 11, 2024 · 1 comment

Comments

@judson-firebolt
Copy link

judson-firebolt commented Jul 11, 2024

Describe the bug
The following query gets split into two, when it shouldn't be:

SELECT (')\'');a');

To Reproduce

https://sqlformat.org/

SELECT (')\'');a');

Yields:

SELECT (')\'');

a');

Expected behavior
The query should come out unchanged

Versions (please complete the following information):
Python: 3.12.1
sqlparse: 0.5.0

andialbrecht added a commit that referenced this issue Jul 15, 2024
andialbrecht added a commit that referenced this issue Jul 15, 2024
@andialbrecht
Copy link
Owner

hm... not sure if it's actually a bug... Some SQL dialects allow quoting a single quote by using a backslash (see https://learnsql.com/cookbook/how-to-escape-single-quotes-in-sql/ for examples).

But I think that is ambiguous. I tried the exact statement in DataGrip using a PostgreSQL database. And the returned value was the complete string )\');a. But the syntax highlighting messed it up ;-)
I really don't know how PostgreSQL (in my case) interprets this example as the double single quotes '' can escape a single quote as well.

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

2 participants