Skip to content
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

make that table "delete" returns the count of deleted objects #1155

Open
jcouto opened this issue Mar 19, 2024 · 2 comments
Open

make that table "delete" returns the count of deleted objects #1155

jcouto opened this issue Mar 19, 2024 · 2 comments
Assignees

Comments

@jcouto
Copy link

jcouto commented Mar 19, 2024

Request to change the return behavior of "delete"

Problem

The table delete method returns the number of objects that fit the query as "delete_count".
When the delete is aborted it returns a positive number.

Workaround

If inside the inherited delete method, check the len(self) to know if deleted.

Requirements

Return the number of deleted objects

Justification

This can be used to perform actions only if the objects were deleted

Related Errors

There are no errors but it is not intuitive that when no objects are deleted the function returns the number of objects that could have been deleted. :)

@dimitri-yatsenko
Copy link
Member

dimitri-yatsenko commented Mar 20, 2024

I do not believe that the problem description is accurate. delete_count is returned by the database as the actual number of rows deleted when successful. If the delete is aborted, then no rows should be deleted. Deletes are atomic: all or none. I think the real issue is in the incorrect reporting of deleted records when the delete is rolled back. It should be set to zero.

@jcouto
Copy link
Author

jcouto commented Mar 20, 2024

I agree, thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants