Fix string parameters losing apostrophes when interpolated into SQL - #1674
Open
zajacmp3 wants to merge 2 commits into
Open
Fix string parameters losing apostrophes when interpolated into SQL#1674zajacmp3 wants to merge 2 commits into
zajacmp3 wants to merge 2 commits into
Conversation
Signed-off-by: Mateusz Zajac <biuro@mzeds.pl>
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.
Description
ixed string parameters silently losing apostrophes when
supportManyParameters=1interpolates them into SQL.SQLInterpolatorescaped'as the SQL-standard'', which Databricks does not implement:'O''Brien'is read as the adjacent literals'O'and'Brien'and concatenated, soO'Brienwas stored asOBrien. Quotes are not escaped as\', consistent with the backslash escaping already applied to\,\n,\rand\t. Data written through this path before the upgrade still holds the stripped values, so lookups that now send the apostrophe (WHERE name = ?bound toO'Brien) no longer match those rows. Only values written withsupportManyParameters=1are affected; correcting them requires a data fix.Why this does not change behaviour for anything that worked before
case '\''branch is the only thing thatchanged; every other input takes exactly the path it took before. The
\,\n,\r,\tandsupplementary-plane branches, the
BINARY/hex-literal path guarded byHEX_LITERAL_PATTERN(SEC-20590),NULLhandling,TIMESTAMP/DATEquoting and numeric pass-through are all untouched.interpreted as the caller intended — the value arrived at the server with its quotes removed. So the change
is a no-op for inputs that worked and a fix for inputs that did not; there is no third category.
''contributes aneven number of quotes;
\'is a single escaped quote inside one literal. Backslashes in the input are stillescaped first (
\->\\), so an input ending in a backslash cannot close the literal early:a\'bemits'a\\\'b', which the server reads back asa\'b. Statement structure is unchanged either way; only thevalue the server stores differs.
Testing
Running batch inserts with supportManyParameters=1 against real databricks instance
Telemetry Errors
DatabricksDriverErrorCodewhere appropriate, and anynew code is uniquely numbered and tested.
requested because the author cannot access the classification.
Additional Notes to the Reviewer