Repository navigation
Preserve dialect-variant type-bound constraints when copying tables - #57
Open
nicoloesch wants to merge 5 commits into
Open
nicoloesch wants to merge 5 commits into
nicoloesch wants to merge 5 commits into
Conversation
Table.to_metadata() regenerates each column's type via Column._copy(), which drops with_variant() dialect overrides, and separately skips type-bound constraints (e.g. Enum's create_constraint CHECK) outright, expecting that regenerated type to recreate them on attach. A variant-wrapped type's generic impl has no constraint to generate, so without_cross_engine_foreign_keys() silently dropped CHECK constraints for any copied table using with_variant() -- surfaced by omop-graph's DuckDB-variant PredicateKind enum crossing a schema boundary. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
gkennos
requested changes
Nov 17, 2026
This branch has not been deployed
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 #56
without_cross_engine_foreign_keys()silently dropped awith_variant()column's CHECK constraint when copying a table whose FK crosses a boundary it strips (another database, or another physical schema on a dialect that cannot express cross-schema keys).Table.to_metadata()regenerates each column's type, droppingwith_variant()overrides, and skips re-copying type-bound constraints, expecting the regenerated type to recreate them, which it cannot once the variant is gone.to_metadata(), and re-copy any type-bound constraint it skipped.Checklist
fix)uv run pytest -q): 584 passeduv run pytest -q -m postgresql): 109 passeduv run ruff check .)