-
Notifications
You must be signed in to change notification settings - Fork 15
[ES-1867329] Quote bind parameter names with backticks #60
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
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7ec19e7
Quote bind parameter names containing non-identifier characters
msrathore-db 6326588
Simplify to unconditional backtick quoting, gate behind flag
msrathore-db 2d9695d
Drop opt-out flag, switch to template-based backtick quoting
msrathore-db f8b4ac9
Replace property descriptors with conventional bindparam_string override
msrathore-db 179e49e
Cover IN-clause expansion at render_postcompile=True time too
msrathore-db 2ac6b6b
Simplify: fix templates on the class via property descriptors
msrathore-db bcb7015
Collapse template properties to inline one-liners
msrathore-db 05c180f
Add DEBUG log on compile and verify insertmanyvalues path
msrathore-db 010803e
Drop the DEBUG log — redundant with sqlalchemy.engine's own logging
msrathore-db 9414d89
Fix lint: black formatting and mypy assignment override
msrathore-db 2c1bc55
Handle literal backtick in column name by doubling per SQL grammar
msrathore-db 9742a30
Close combined-case gap: backtick AND default-escape char in same name
msrathore-db c9a8412
Remove test_full_audit.py — local probe script, not a repo artifact
msrathore-db File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we check for a literal backtick in column name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes — added in the most recent commits (2c1bc55 and 9742a30).
Two places where it needed to be addressed:
DDL (
DatabricksIdentifierPreparer, _ddl.py:13-19) — passescape_quote=""so SQLAlchemy doubles backticks inside quoted identifiers (it was using the default"and producing invalid DDL like ``ab``).Bind markers (
DatabricksStatementCompiler.bindparam_string, _ddl.py:135-166) — when the column name contains a literal backtick, render the marker ourselves with the backtick doubled (:`ab``). The params dict key stays the single-backtick original since the server un-doubles when it parses the marker name. We bypass super's default escape map for this path so it can't interact and create a mismatch (e.g., a column like `` colx.y `` with both a backtick and a dot).Test coverage:
tests/test_local/test_ddl.py::TestBindParamQuoting::test_literal_backtick_in_column_name_is_doubled— DDL + INSERT marker + dict keytests/test_local/test_ddl.py::TestBindParamQuoting::test_backtick_combined_with_default_escape_chars— combined backtick + dotCREATE TABLE→INSERT→SELECT WHERE→DROPround-trip on a column nameda`bpasses.