Skip to content

Commit 5b6f3dc

Browse files
fix: accept **kwargs in Bool.__init__ for SQLAlchemy type compatibility (#706)
* chore: add CHANGELOG entry for Bool kwargs fix * add test, move location of changelog entry --------- Co-authored-by: Joe Spadola <joe.spadola@clickhouse.com>
1 parent 4d2dffa commit 5b6f3dc

3 files changed

Lines changed: 9 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
### Bug Fixes
66
- Async client: retry once when a pooled keep-alive connection is closed by the server and aiohttp raises `ServerDisconnectedError` with the default `"Server disconnected"` message. The existing retry path covered `"Connection reset"` and `"Remote end closed"`, but not the bare `ServerDisconnectedError()` produced by recent aiohttp versions, which surfaced as an `OperationalError("Network Error: Server disconnected")` on the first request after an idle period.
7+
- SQLAlchemy `Bool` type now accepts and forwards `**kwargs` to the underlying `SqlaBoolean` constructor. SQLAlchemy's `SchemaType` machinery passes internal kwargs (e.g., `_create_events`) when copying or adapting the type during ORM model use or `Table.to_metadata()`, which previously raised a `TypeError`. Fixes [#705](https://github.com/ClickHouse/clickhouse-connect/issues/705)
78

89
## 1.0.0rc1, 2026-04-22
910

clickhouse_connect/cc_sqlalchemy/datatypes/sqltypes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ def __init__(self, type_def: TypeDef = EMPTY_TYPE_DEF):
9191

9292

9393
class Bool(ChSqlaType, SqlaBoolean):
94-
def __init__(self, type_def: TypeDef = EMPTY_TYPE_DEF):
94+
def __init__(self, type_def: TypeDef = EMPTY_TYPE_DEF, **kwargs):
9595
ChSqlaType.__init__(self, type_def)
96-
SqlaBoolean.__init__(self)
96+
SqlaBoolean.__init__(self, **kwargs)
9797

9898

9999
class Boolean(Bool):

tests/unit_tests/test_sqlalchemy/test_types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from sqlalchemy import DateTime, Integer
22

33
from clickhouse_connect.cc_sqlalchemy.datatypes.base import sqla_type_from_name, sqla_type_map
4-
from clickhouse_connect.cc_sqlalchemy.datatypes.sqltypes import DateTime64, Int64, LowCardinality, Nullable, QBit, String
4+
from clickhouse_connect.cc_sqlalchemy.datatypes.sqltypes import Bool, DateTime64, Int64, LowCardinality, Nullable, QBit, String
55

66

77
def test_mapping():
@@ -30,6 +30,11 @@ def test_low_cardinality():
3030
assert lc_str.name == "LowCardinality(Nullable(String))"
3131

3232

33+
def test_bool_accepts_schema_kwargs():
34+
# SQLAlchemy's SchemaType copy/adapt path passes internal kwargs like _create_events
35+
Bool(_create_events=False)
36+
37+
3338
def test_qbit():
3439
qbit = sqla_type_from_name("QBit(Float32, 768)")
3540
assert qbit.__class__ == QBit

0 commit comments

Comments
 (0)