Skip to content

fix: comma-separated --schema/--exclude_schema silently matched nothing - #12

Merged
leochong merged 1 commit into
mainfrom
fix/multi-schema-filtering
Aug 14, 2026
Merged

fix: comma-separated --schema/--exclude_schema silently matched nothing#12
leochong merged 1 commit into
mainfrom
fix/multi-schema-filtering

Conversation

@leochong

@leochong leochong commented Aug 9, 2026

Copy link
Copy Markdown

Summary

  • --schema public,reporting was documented in the README as supported ("Multiple schemas (comma-separated)"), but the raw comma-joined string was passed straight through to schemainspect's filter_schema(), which compares it for exact equality against each object's schema name — "public,reporting" never equals "public" or "reporting", so the diff was silently empty with no error. Single-schema (--schema public) and no-schema calls were never affected — this only broke 2+ comma-separated names.
  • Adds parse_schema_arg() / filter_inspector_schemas() in migra/util.py. filter_inspector_schemas() reuses schemainspect's own PROPS list (the same one its filter_schema() iterates over) instead of hardcoding a second copy, so it can't silently drift out of sync as schemainspect adds new object types.
  • Adds _get_inspector() in migra/migra.py, used at all 5 of Migration's inspector-construction call sites (__init__ x2, inspect_from(), inspect_target(), apply()). Single-schema/no-schema calls are passed straight through to the original get_inspector() unchanged — zero behavior change there; only 2+ comma-separated names take the new post-filter path.

Test plan

  • New tests in test_migra.py: test_multischema, test_multischema_whitespace_tolerant (surrounding whitespace in the comma list), test_exclude_multischema — each fixture (tests/FIXTURES/multischema/, tests/FIXTURES/exclude_multischema/) includes a third, unlisted schema so the assertions prove real filtering (expected cross-schema changes present, third-schema changes absent), not just "happens to work with one schema"
  • These tests exercise both the CLI path (run()) and Migration.apply() directly, via do_fixture_test's existing two-phase structure
  • Full suite: 356 passed, 2 skipped, no regressions
  • flake8 + black clean

🤖 Generated with Claude Code

--schema public,reporting was documented as supported but the raw
comma-joined string was passed straight through to schemainspect's
filter_schema(), which compares it for exact equality against each
object's schema name -- "public,reporting" never equals "public" or
"reporting", so the diff was always empty with no error. Single-schema
and no-schema calls were never affected.

Adds parse_schema_arg()/filter_inspector_schemas() in migra/util.py
(the latter reuses schemainspect's own PROPS list rather than a
hardcoded copy, so it can't drift out of sync) and _get_inspector() in
migra/migra.py, wired into all 5 of Migration's inspector-construction
call sites. Single/no-schema calls pass straight through to the
original get_inspector() unchanged; only 2+ comma-separated names take
the new post-filter path.

New tests each include a third, unlisted schema in the fixture data to
prove real filtering rather than "happens to work with one schema",
and exercise both the CLI path and Migration.apply() directly.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@leochong
leochong merged commit 9c553ba into main Aug 14, 2026
14 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.

1 participant