Skip to content

♻️ Remove redundant item deletion logic in backend/app/api/routes/users.py‎#2253

Open
raphaeltannous wants to merge 2 commits into
fastapi:masterfrom
raphaeltannous:fix/cascade-delete-redundancy
Open

♻️ Remove redundant item deletion logic in backend/app/api/routes/users.py‎#2253
raphaeltannous wants to merge 2 commits into
fastapi:masterfrom
raphaeltannous:fix/cascade-delete-redundancy

Conversation

@raphaeltannous
Copy link
Copy Markdown

Hey!

Removed redundant manual item deletion in the user deletion endpoint, since the SQLModel relationship already has ON DELETE CASCADE configured, which automatically deletes all related items when a user is deleted.

owner_id: uuid.UUID = Field(
foreign_key="user.id", nullable=False, ondelete="CASCADE"
)

Copy link
Copy Markdown
Member

@YuriiMotov YuriiMotov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!
But we should then add tests that check that items are also deleted.
Currently tests don't check that: https://github.com/fastapi/full-stack-fastapi-template/blob/master/backend/tests/api/routes/test_users.py

@YuriiMotov YuriiMotov changed the title Refactor redundant user deletion logic in users.py ♻️ Remove redundant item deletion logic in backend/app/api/routes/users.py‎ May 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants