Rewrite merge methods on real Core constructs so schema_translate_map applies to loaded data - #39
Open
nicoloesch wants to merge 23 commits into
Open
nicoloesch wants to merge 23 commits into
nicoloesch wants to merge 23 commits into
Conversation
added 5 commits
August 28, 2026 01:21
…t SQLAlchemy core objects, update test suite and unify shared backend tests, update schema registration
4 tasks
added 10 commits
September 3, 2026 05:55
gkennos
self-requested a review
September 20, 2026 23:50
gkennos
reviewed
Sep 21, 2026
gkennos
requested changes
Sep 21, 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
Depends on AustralianCancerDataNetwork/oa-configurator#37.
Requires
pyproject.tomlversion update foroa-configuratorBreaking change
OrmLoaderConfig.test_orm_dbis gone, replaced bytest_orm_db_pg/test_orm_db_sqlite. Anyone withtest_orm_dbset in theiromop.configwill need to update it. There is no back-compat shim. Needed because dialect-specific integration tests require a guaranteed-correct-dialect test database each, which one shared field couldn't express.Root cause
Four related ways
schema_translate_mapwas silently bypassed across orm-loader:merge_replace/merge_insert/merge_upsertbuilt raw, unqualifiedtext()SQLsa.inspect()schemastring instead of resolving through the connection, andFix
Loaded/merged data
merge_replace/merge_insert/merge_upsertrewritten against realTableobjects anddialect-specific Core constructs (
sa.delete,insert().from_select(),postgresql.insert().on_conflict_do_nothing(), with a SQLite-specific counterpart), for both backends.isolation_level="AUTOCOMMIT"call site.connection()to prevent data lossMaterialized views
create_mv/refresh_mv/drop_mv/index creation are fully role-awareschema_translate_map(__mv_schema_tag__, defaulting toRole.PRIMARY)_as_connection()context manager, replacing a narrower per-method check that only ever guarded direct/manualPostgresBackend()construction.manage_indices) now resolves itsInspectorschema-aware, viaphysical_schema_of(session, schema_tag=validate_schema_tag(cls.__table__)).Split primary/vocab connections
Config, CI, test infrastructure
STAGING_SCHEMA's reserved-schema registration moved intoconfig.py(the actualomop.configentry point), so it's guaranteed to run whenever this package's config is resolvableOrmLoaderConfig.test_orm_dbsplit intotest_orm_db_pg/test_orm_db_sqlitefor dialect-specific test configurationsengine_with_replica_rolenow usesautocommit_connection()'sEnginebranch directlyDialectsystem in favour of the unifiedoa-configuratoroneoa-configurator's new test infrastructure (isolated_test_database,DIALECT_PARAMS,db_dialectmarker).-
test_schema_translate_map.py: the actual regression test for the originally-reportedbug,
test_split_connection.py,test_shared_backend.py: merge-method contract tests unified across both dialects,test_reserved_schema.py: provesSTAGING_SCHEMAregistration is actuallyenforced cross-package
Schema drift protection, primitive consolidation
helpers/bootstrap.py::create_db/bootstrap()is now wrapped inguard_schema_provenance_forvia oa-configurator'sopen_connectionto prevent schema drifthelpers/sql.py::qualify_identifierdeleted entirelyqualified()backends/base.py::_as_connectionnow delegates its Engine/Connection branch to oa-configurator'sopen_connection.physical_schema_ofstack-widevalidate_schema_tagusage inmaterialised_view_mixin.pyandschema_if_supportedusage inbackends/sqlite.py.Checklist
breaking,feature,fix,dependencies, orchore)uv run pytest -q): 246 passed, 1 xfaileduv run pytest -q -m postgresql): 37 passeduv run ruff check .)