on_delete should be required in all type relations #1801.#1911
Open
FluckyGo wants to merge 1 commit intotortoise:developfrom
Open
on_delete should be required in all type relations #1801.#1911FluckyGo wants to merge 1 commit intotortoise:developfrom
FluckyGo wants to merge 1 commit intotortoise:developfrom
Conversation
e517a43 to
4060672
Compare
Author
|
This PR is designed to get rid of the implicit behavior when dealing with any type of relations. |
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.
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: