Skip to content

fix: accept **kwargs in Bool.__init__ for SQLAlchemy type compatibility#706

Merged
joe-clickhouse merged 6 commits into
ClickHouse:mainfrom
Bahtya:fix/bool-sqlalchemy-compat
Apr 30, 2026
Merged

fix: accept **kwargs in Bool.__init__ for SQLAlchemy type compatibility#706
joe-clickhouse merged 6 commits into
ClickHouse:mainfrom
Bahtya:fix/bool-sqlalchemy-compat

Conversation

@Bahtya
Copy link
Copy Markdown
Contributor

@Bahtya Bahtya commented Apr 8, 2026

Problem

Using Bool from clickhouse_connect.cc_sqlalchemy.datatypes.sqltypes in SQLAlchemy ORM models fails with:

TypeError: Bool.__init__() got an unexpected keyword argument _create_events

This makes the Bool type unusable in ORM models.

Root Cause

SQLAlchemy internally copies/adapts types by calling __init__(**kwargs) with additional keyword arguments like _create_events. The Bool.__init__ only accepts type_def, so these extra kwargs cause a TypeError.

Solution

Accept **kwargs in Bool.__init__ and forward them to SqlaBoolean.__init__(self, **kwargs).

Fixes #705

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Apr 8, 2026

CLA assistant check
All committers have signed the CLA.

@Bahtya
Copy link
Copy Markdown
Contributor Author

Bahtya commented Apr 8, 2026

I have read the CLA Document and I hereby sign the CLA.

@joe-clickhouse
Copy link
Copy Markdown
Contributor

Thanks for the fix @Bahtya! If you could just update the CHANGELOG and sign the CLA we'll be good to merge. Thanks.

@Bahtya
Copy link
Copy Markdown
Contributor Author

Bahtya commented Apr 14, 2026

Thanks @joe-clickhouse! I have signed the CLA. I will update the CHANGELOG shortly.

@Bahtya Bahtya force-pushed the fix/bool-sqlalchemy-compat branch from a81ad37 to 440e4a2 Compare April 14, 2026 09:45
@Bahtya
Copy link
Copy Markdown
Contributor Author

Bahtya commented Apr 17, 2026

Hi @joe-clickhouse, I've added the CHANGELOG entry. Regarding the CLA, I'll sign it shortly. Thanks for the quick review!

@joe-clickhouse
Copy link
Copy Markdown
Contributor

Hey @MrSyta to officially sign the CLA you'll need to actually click on the link https://cla-assistant.io/ClickHouse/clickhouse-connect?pullRequest=706 and click through the acknowledgment there. Thanks!

@Bahtya
Copy link
Copy Markdown
Contributor Author

Bahtya commented Apr 18, 2026

@joe-clickhouse Thank you for the guidance. I see the CLA needs to be signed through the web interface at the cla-assistant.io link. I'll complete that step shortly. The CHANGELOG entry is already added. Apologies for the delay!

@joe-clickhouse
Copy link
Copy Markdown
Contributor

@Bahtya hope you don't mind, but I moved the changelog note to the unreleased section and added a minimal regression test. Thanks again for the work!

Copy link
Copy Markdown
Contributor

@joe-clickhouse joe-clickhouse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@joe-clickhouse joe-clickhouse merged commit 5b6f3dc into ClickHouse:main Apr 30, 2026
33 checks passed
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.

Bool type incompatible with SQLAlchemy

3 participants