Conversation
… corruption User-provided filter values containing '?' were inlined into raw SQL as string literals via unsafeSQLString. The escapeCharMap escaped quotes and backslashes but not '?', so sqlx.Rebind replaced those literal '?' characters with PostgreSQL $N placeholders, corrupting the query and causing 'could not determine data type of parameter' errors. Adding '?' → '??' to the escape map: sqlx's PostgreSQL Rebind treats '??' as an escaped literal '?' and emits it unchanged, preventing user-supplied '?' characters from being misinterpreted as placeholders. Fixes temporalio#11797 Signed-off-by: simpleqt <89645338+simpleqt@users.noreply.github.com>
|
|
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.
Fixes #11797
What
Added ? → ?? to the escapeCharMap in query_converter.go. Without this, user-provided filter values containing ? were inlined into the raw SQL as string literals (via unsafeSQLString), and sqlx.Rebind replaced every ? character — including those inside string literals — with PostgreSQL dollar-N placeholders, corrupting the query and causing 'could not determine data type of parameter' errors.
Why
escapeCharMap already escaped quotes, backslashes, and control characters, but not ?. sqlx's PostgreSQL Rebind treats bare ? as a placeholder position marker. ?? is the sqlx-standard escape for a literal ? and is left unchanged by Rebind.
How tested
Manual verification: ? in a filter value now survives Rebind as a literal ? inside the string literal, and the query executes without placeholder errors.
Signed-off-by: simpleqt 89645338+simpleqt@users.noreply.github.com