Skip to content

fix(orm): honor polymorphic write lifecycle (F07) - #240

Merged
andrewzolotukhin merged 1 commit into
developmentfrom
fix/polymorphic-write-lifecycle
Oct 3, 2026
Merged

andrewzolotukhin merged 1 commit into
developmentfrom
fix/polymorphic-write-lifecycle

Conversation

@andrewzolotukhin

Copy link
Copy Markdown
Contributor

Variant updates and deletes bypassed the ordinary lifecycle pipeline, so soft-deletable polymorphic entities were physically removed and hooks/timestamps were skipped. This change makes explicit ofVariant() writes and tracked polymorphic saveChanges() use one atomic pipeline for STI and CTI.

  • Honor base-schema soft deletion, retaining CTI child data; add restore() and hardDelete() with typed return values.
  • Run base/variant hooks once, map updates to the correct tables/columns, and maintain configured timestamps and exact storage values.
  • Capture and lock targets inside the transaction, recheck predicates after lock waits, and use savepoints for caller-owned transactions. Preserve optimistic concurrency and only advance tracked values/snapshots after success.
  • Fix extension-managed deletion-column visibility; preserve captured scopes and avoid reapplying them to returning rows. Guard identity changes and writes through projections/loaded relations.

The coordinated v5 major changeset and migration guide explain the deletion change: consumers requiring physical removal must use hardDelete().

Validation: npm run lint, npm run build, npm run test (4,721 tests, no type errors), both website typechecks, and npm run test:queries:integration against PostgreSQL 16 (85 tests, including 26 F07 regressions). Coverage includes STI/CTI lifecycle behavior, tracked inserts/updates/deletes, savepoint/outer rollback, FK and hook failures, scopes/pagination, stale versions, concurrent predicate changes, exact bigint keys, and write-surface type checks.

@andrewzolotukhin
andrewzolotukhin merged commit 016b1cc into development Oct 3, 2026
3 checks passed
@andrewzolotukhin
andrewzolotukhin deleted the fix/polymorphic-write-lifecycle branch October 3, 2026 05:38
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