We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
The regex for determining a tokens.String.Single seems incorrect, i.e., it is too greedy, when the SQL contains an escape character:
tokens.String.Single
>>> from sqlparse import parse >>> stmt = parse(r"foo = '\' AND bar = 'baz'")[0] >>> stmt._pprint_tree() |- 0 Identifier 'foo = ...' | |- 0 Comparison 'foo = ...' | | |- 0 Identifier 'foo' | | | `- 0 Name 'foo' | | |- 1 Whitespace ' ' | | |- 2 Comparison '=' | | |- 3 Whitespace ' ' | | `- 4 Single ''\' AN...' | `- 1 Identifier 'baz' | `- 0 Name 'baz' `- 1 Error "'"
I'm not sure why the ' is present in ...|\\'|... and was wondering whether this should be removed.
'
...|\\'|...
The text was updated successfully, but these errors were encountered:
To my knowledge, MySQL and BigQuery are one of the few databases that support escaping single quotes using a backslash: https://dev.mysql.com/doc/refman/8.0/en/string-literals.html#character-escape-sequences and https://cloud.google.com/bigquery/docs/reference/standard-sql/lexical#literals. But all other databases I can think of will retain the backslash when when placed before the single quote:
SELECT '\'' as test
ERROR
SELECT '\''' as test
\'
Sorry, something went wrong.
No branches or pull requests
The regex for determining a
tokens.String.Single
seems incorrect, i.e., it is too greedy, when the SQL contains an escape character:I'm not sure why the
'
is present in...|\\'|...
and was wondering whether this should be removed.The text was updated successfully, but these errors were encountered: