Skip to content

on_delete should be required in all type relations #1801. #1911

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

FluckyGo
Copy link

@FluckyGo FluckyGo commented Mar 1, 2025

My changes remove the default CASCADE behavior for the on_delete parameter in all relationship types, making it mandatory and the behavior obvious and predictable.
This will help prevent accidental data loss when implicitly cascading deletes.
All tests have been updated to explicitly specify the on_delete value.

Fixes #1801

Description
This helps prevent accidental data loss caused by implicit cascading deletes, which developers might overlook due to the default CASCADE behavior. By requiring on_delete to be explicitly defined, we ensure that deletion behavior is always clear and intentional..

Motivation and Context
Issue #1801 highlighted the default on_delete=CASCADE behavior as a potential risk for data loss. Users reported that unintended cascading deletions could occur, particularly when developers were unaware of the default setting. To enhance data safety, this change now requires explicit configuration of the deletion behavior.

How Has This Been Tested?
Ran the full test suite using pytest.
Tested on Python 3.9, 3.10, 3.11, 3.12, 3.13 with SQLite/PostgreSQL.

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added the changelog accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@FluckyGo FluckyGo force-pushed the on_delete-mandatory branch from e517a43 to 4060672 Compare March 1, 2025 15:02
@FluckyGo FluckyGo changed the title on_delete should be required #1801. on_delete should be required in all type relations #1801. Mar 1, 2025
@FluckyGo
Copy link
Author

FluckyGo commented Mar 1, 2025

This PR is designed to get rid of the implicit behavior when dealing with any type of relations.

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.

on_delete should be required
1 participant