Correctly encode array for native param binding#257
Merged
isublimity merged 1 commit intosmi2:masterfrom Apr 16, 2026
Merged
Conversation
Contributor
|
Thanks a lot for the fix — really useful catch! 🎉 The Merged to master. I'll add a follow-up commit to escape single quotes and backslashes inside array strings (e.g. |
isublimity
added a commit
that referenced
this pull request
Apr 16, 2026
Follow-up to #257: properly escape single quotes and backslashes in Array(String) native parameter values to prevent query errors and array-element injection. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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.
Fix incorrect array encoding for native parameter binding
Problem
When passing an Array type to selectWithParams() or writeWithParams(), the previous implementation serialized the array using json_encode():
This produced JSON encoding — double-quoted strings and JSON syntax:
["foo","bar","baz"]ClickHouse's native HTTP parameter protocol expects array literals with single-quoted strings:
['foo','bar','baz']The double-quoted output caused a query error when executing any native param query with a Array(String) parameter.
Fix
Replaced json_encode with a recursive approach that delegates each element back through convertParamValue(), with a special case for string elements which are wrapped in single
quotes:
This correctly handles: