Skip to content

fix: call manage_relationships in single hard destroy path#2596

Merged
zachdaniel merged 2 commits intomainfrom
fix/single-destroy-manage-relationships
Feb 27, 2026
Merged

fix: call manage_relationships in single hard destroy path#2596
zachdaniel merged 2 commits intomainfrom
fix/single-destroy-manage-relationships

Conversation

@barnabasJ
Copy link
Contributor

Summary

  • Single hard destroy actions silently ignored manage_relationship changes — the commit/3 function in destroy.ex never called manage_relationships, unlike create, update, soft destroy, and bulk destroy paths
  • Adds manage_relationships/4 to Ash.Actions.Destroy following the same pattern from Ash.Actions.Update (lines 728-757)
  • Pipes the data layer result through manage_relationships before the notification/select pipeline, and propagates relationship notifications instead of hardcoding []
Action Type Single Bulk
Create Works Works
Update Works Works
Destroy (hard) Fixed Works
Destroy (soft) Works (delegates to Update) Works

Test plan

  • 5 single hard destroy tests (create/update/soft-destroy/hard-destroy related, error propagation)
  • 3 single soft destroy tests (create related, direct_control, error propagation)
  • 3 bulk hard destroy tests (create related, direct_control, error propagation)
  • 1 bulk soft destroy test (direct_control)
  • All 2779 existing tests pass (0 failures)
  • ash_postgres bulk_manage_relationship_rollback_test.exs — 20/20 pass with local ash

Related: ash-project/ash_postgres#702

The single hard destroy path in `destroy.ex` never called
`manage_relationships`, causing any `manage_relationship` changes
declared on hard destroy actions to be silently ignored. The bulk
destroy, soft destroy, create, and update paths all properly called
`manage_relationships`.

Adds `manage_relationships/4` to `Ash.Actions.Destroy` following the
same pattern used in `Ash.Actions.Update`, and pipes the data layer
result through it before the notification/select pipeline.

Also adds comprehensive tests for manage_relationship on destroy
actions: single hard destroy, single soft destroy, bulk hard destroy,
and bulk soft destroy.

Closes ash-project/ash_postgres#702
@zachdaniel zachdaniel merged commit c3e3d7c into main Feb 27, 2026
45 checks passed
@zachdaniel
Copy link
Contributor

🚀 Thank you for your contribution! 🚀

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.

2 participants