Skip to content

fix: serialize nil query parameters to \N instead of NULL (#1760)#1797

Open
DobryySoul wants to merge 3 commits intoClickHouse:mainfrom
DobryySoul:fix-1760-null-query-params
Open

fix: serialize nil query parameters to \N instead of NULL (#1760)#1797
DobryySoul wants to merge 3 commits intoClickHouse:mainfrom
DobryySoul:fix-1760-null-query-params

Conversation

@DobryySoul
Copy link
Copy Markdown

Resolves #1760.

What changes did you make?

When passing nil to a query parameter (e.g. {is_etf:Nullable(Bool)}), the driver previously serialized it as the string literal "NULL". Because native Query Parameters in ClickHouse are passed in the TabSeparated format over HTTP/TCP, ClickHouse expects \N for SQL NULLs instead. Sending "NULL" caused parsing errors like Cannot parse boolean value here: 'NULL'.

This PR fixes the formatting inside bindQueryOrAppendParameters() so that it correctly serializes nil as \N for query parameters, while leaving the legacy string replacement behavior intact.

Checklist:

  • Added unit tests for query parameters binding to ensure nil translates to \N and other types remain unaffected
  • Added integration tests for both Native and HTTP protocols (tests & tests/std) to verify Nullable parameters on a real server
  • Verified tests pass locally using make test

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Mar 14, 2026

CLA assistant check
All committers have signed the CLA.

…#1760)

Resolves ClickHouse#1760. When using native query parameters like {param:Nullable(Type)}, ClickHouse expects nil/NULL values to be encoded as '\N' in the tab-separated payload, but the driver previously passed the string literal 'NULL'.
@DobryySoul DobryySoul force-pushed the fix-1760-null-query-params branch from be2dede to 1659fe8 Compare March 16, 2026 15:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Query Parameter Nullable(T) does not accept nils

2 participants