fix(sqlalchemy): support explicit multi-row inserts (#1024) - #1025
Merged
Conversation
Signed-off-by: Joe Spadola <joe.spadola@clickhouse.com>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The change is narrowly scoped (dialect capability flag) and is backed by both unit and integration tests plus aligned documentation and changelog coverage.
Pull request overview
This PR enables SQLAlchemy Core explicit multi-row inserts using Insert.values([...]) for the ClickHouse Connect dialect by opting the dialect into SQLAlchemy's multi-values INSERT capability, and adds coverage and documentation for the supported forms (dict rows, tuple rows, and per-row SQL expressions).
Changes:
- Enable SQLAlchemy multi-row
Insert.values()support viasupports_multivalues_insert = Trueon the dialect. - Add unit and integration tests validating compilation and execution behavior for both client-side and server-side bind parameter modes.
- Document the supported multi-row insert forms and add a changelog entry describing the user-visible behavior.
File summaries
| File | Description |
|---|---|
| tests/unit_tests/test_sqlalchemy/test_server_side_params.py | Adds compile-time coverage for multi-row inserts and a routing test to confirm explicit multi-row inserts use the text execution path while executemany uses native bulk insert. |
| tests/integration_tests/test_sqlalchemy/test_server_side_params.py | Adds end-to-end verification that multi-row Insert.values([...]) executes correctly for dicts, tuples, and per-row expressions in both bind modes. |
| docs/sqlalchemy.mdx | Documents explicit multi-row Insert.values([...]) support and guidance on when to prefer native bulk insert vs server-side params. |
| clickhouse_connect/cc_sqlalchemy/MIGRATING_FROM_CLICKHOUSE_SQLALCHEMY.md | Updates migration guidance to note explicit multi-row Core inserts are supported and when to use native bulk insert vs server-side params. |
| clickhouse_connect/cc_sqlalchemy/dialect.py | Enables SQLAlchemy multi-values INSERT capability on the dialect. |
| CHANGELOG.md | Adds an UNRELEASED improvements entry describing the new SQLAlchemy behavior and related Pandas to_sql(method="multi") enablement. |
Review details
- Files reviewed: 6/6 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Enable SQLAlchemy multi-row
insert.values(), including per-row expressions.Closes #1024
Checklist
Delete items not relevant to your PR: