Repository navigation
Conversation
When SQL queries executed through the DB-API driver contained non-ASCII characters (such as accented characters in table names, string values, or comments), an internal routine attempted to automatically wrap those words in backticks. Due to a bug in that routine, any SQL text following the non-ASCII character was silently discarded. For targeted UPDATE and DELETE statements (such as deleting a single row by ID), stripping the trailing WHERE clause caused the driver to detect an unqualified statement and automatically append "WHERE 1=1", turning a scoped single-row modification into an accidental full-table wipe. Additionally, string literals containing Unicode characters were erroneously converted into column identifiers, and adjacent punctuation was corrupted. This change removes the legacy auto-backticking routine entirely. The database driver now treats incoming SQL statements as transparent text rather than attempting to guess and quote identifiers using regular expressions. Frameworks like SQLAlchemy and Django already quote identifiers safely at the query compiler level. Query preprocessing in the driver is now limited strictly to translating parameter placeholders and unescaping literal percent signs. Comprehensive regression tests have been added to ensure queries containing Unicode table names, string literals, and comments preserve their complete WHERE predicates.
Contributor
There was a problem hiding this comment.
Code Review
This pull request removes the sanitize_literals_for_upload and backtick_unicode helper functions, replacing their usage with a simple sql.replace("%%", "%") to prevent the unintended backticking or modification of Unicode characters in SQL identifiers, string literals, and predicates. It also adds comprehensive unit tests to ensure Unicode is correctly preserved across various SQL statements. I have no feedback to provide as there are no review comments.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When SQL queries executed through the DB-API driver contained non-ASCII characters (such as accented characters in table names, string values, or comments), an internal routine attempted to automatically wrap those words in backticks. Due to a bug in that routine, any SQL text following the non-ASCII character was silently discarded.
For targeted UPDATE and DELETE statements (such as deleting a single row by ID), stripping the trailing WHERE clause caused the driver to detect an unqualified statement and automatically append "WHERE 1=1", turning a scoped single-row modification into an accidental full-table wipe. Additionally, string literals containing Unicode characters were erroneously converted into column identifiers, and adjacent punctuation was corrupted.
This change removes the legacy auto-backticking routine entirely. The database driver now treats incoming SQL statements as transparent text rather than attempting to guess and quote identifiers using regular expressions. Frameworks like SQLAlchemy and Django already quote identifiers safely at the query compiler level. Query preprocessing in the driver is now limited strictly to translating parameter placeholders and unescaping literal percent signs. Comprehensive regression tests have been added to ensure queries containing Unicode table names, string literals, and comments preserve their complete WHERE predicates.