Repository navigation
Bind top-level Enum server parameters like their value - #1184
Merged
joe-clickhouse merged 2 commits intoNov 12, 2026
Merged
Conversation
joe-clickhouse
approved these changes
Nov 12, 2026
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues were identified for the Enum formatting change, though tests were not run during this review.
No open issues 🎉
What changed in this PR
Addresses #1183 in the shared parameter formatter by making top-level Enum members format like their underlying values, while preserving nested literal formatting.
Changes:
- Preserves
top_levelwhen formatting an Enum's value, correcting quoting and NULL handling. - Adds unit coverage and sync/async integration tests for Enum parameter binding.
- Documents the user-visible fix in the changelog.
No material issues were identified. Tests were not run during this review.
| File | Description |
|---|---|
tests/unit_tests/test_driver/test_params.py |
Adds scalar, nested, and NULL Enum formatting cases. |
tests/integration_tests/test_params.py |
Compares Enum bindings with plain values through both HTTP clients. |
clickhouse_connect/driver/binding.py |
Preserves top-level formatting when unwrapping Enum members. |
CHANGELOG.md |
Documents corrected Enum quoting and NULL behavior. |
Review effort: Balanced
AI review gate — auto-approval withheldThe AI review gate is green, but the approver did not approve What to do: ask someone with write access who is not the PR author to approve this pull request. |
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.
Summary
Fixes #1183
format_bind_valueformatted anEnummember withrecurse(value.value), andrecursealways passestop_level=False. A top-level member with astrordatevalue was therefore sent as a quoted literal:This change passes the caller's
top_levelthrough, so the member formats exactly like its value. Members inside arrays, tuples and maps still format as nested literals, as before. Members ofstrsubclasses such asclass E(str, Enum)already took thestrbranch and do not change. A member whose value isNonenow binds as NULL, the same asNone.Not changed: the type-aware steps in
bind_querythat run before formatting, such asDateTime64promotion, namedTuplefield ordering and the_64suffix, still see theEnumobject and not its value. That was the same before this change.Tests: a unit test in
tests/unit_tests/test_driver/test_params.pycoversstr,int,dateand tuple values at the top level and nested, and an integration test intests/integration_tests/test_params.pybinds members toString,Enum8,Int32,Date,Array(String)andTuple(Date, Int32)through sync and async clients and compares with the plain values. Both fail on main and pass with this change.Checklist
Note
Low Risk
Narrow change to server parameter formatting for standard
Enumtypes, with unit and integration tests; no auth or data-path impact.Overview
Server-side parameter binding now treats a top-level
enum.Enummember as its underlying value instead of always formatting through nested literal rules.In
format_bind_value,Enumhandling callsformat_bind_value(value.value, …, top_level)rather thanrecurse(value.value), so{v:String}getsuser_1'swithout extra quotes,Date/Int32/Enum8bindings work, and a member whose value isNonebinds as SQL NULL (\N) instead of the stringNULL. Enum members inside arrays, tuples, and maps still use nested formatting.strsubclasses such asclass E(str, Enum)are unchanged because they take thestrbranch.Unit and integration tests cover string, int, date, tuple, and NULL cases; the CHANGELOG documents the fix (related to [#1183]).
Reviewed by Cursor Bugbot for commit a9bfa8a. Bugbot is set up for automated code reviews on this repo. Configure here.