tortoise / tortoise/tortoise-orm
on_delete should be required
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 5.6k
- Forks
- 516
- Avg merge
- 2d 21h
- Merged PRs (30d)
- 9
Description
Is your feature request related to a problem? Please describe.
I encountered that when declaring ForeignKeyField on_delete = CASCADE, I believe that this is dangerous and in some scenarios may lead to undesirable consequences.
def ForeignKeyField(
model_name: str,
related_name: Union[Optional[str], Literal[False]] = None,
on_delete: OnDelete = CASCADE,
db_constraint: bool = True,
null: bool = False,
**kwargs: Any,
) -> "ForeignKeyRelation[MODEL] | ForeignKeyNullableRelation[MODEL]":
Describe the solution you'd like
The best solution would be to make on_delete a mandatory parameter, I believe that actions with data should be explicit.
def ForeignKeyField(
model_name: str,
on_delete: OnDelete,
related_name: Union[Optional[str], Literal[False]] = None,
db_constraint: bool = True,
null: bool = False,
**kwargs: Any,
) -> "ForeignKeyRelation[MODEL] | ForeignKeyNullableRelation[MODEL]":
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by locating the ForeignKeyField declaration and reviewing its call sites across the repository. Check how the current default on_delete is documented and tested, then determine the affected usage and update coverage needed when the parameter becomes mandatory.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- database
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100