use bound params and format_str in DDL/inspector#728
Merged
joe-clickhouse merged 3 commits intomainfrom May 5, 2026
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR hardens the SQLAlchemy integration by removing raw string interpolation in reflection/DDL paths, using SQLAlchemy bound parameters and the project’s format_str escaping helper, and fixes invalid Replicated CREATE DATABASE DDL output.
Changes:
- Replace
system.tablesengine lookup string interpolation with a bound-parameter query. - Build Replicated database engine arguments using
format_strand add the missing closing)in emitted DDL. - Add unit tests covering
CreateDatabase/DropDatabaseDDL generation (including escaping).
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
clickhouse_connect/cc_sqlalchemy/inspector.py |
Switches system.tables lookup to a parameterized query for get_engine. |
clickhouse_connect/cc_sqlalchemy/ddl/custom.py |
Uses format_str for Replicated engine args and fixes missing closing ) in emitted DDL. |
tests/unit_tests/test_sqlalchemy/test_create_database.py |
Adds unit tests for database DDL generation and escaping. |
CHANGELOG.md |
Documents the Replicated DDL fix and bound-parameter/escaping changes. |
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
This is a re-implementation of the suggestions from #711.
system.tableslookup from f-string interpolation to SQLA bound parametersformat_strhelper instead of raw f-string interpolation, and fix a missing closing)that made the original Replicated DDL emit invalid SQLChecklist
Delete items not relevant to your PR: