You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
make that table "delete" returns the count of deleted objects #1155
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. :)
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.
Activity
dimitri-yatsenko commentedon Mar 20, 2024
I do not believe that the problem description is accurate.
delete_countis 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 commentedon Mar 20, 2024
I agree, thanks.
github-actions commentedon Mar 14, 2025
This issue is stale because it has been open for 45 days with no activity.
fix: return 0 from delete() when user cancels operation (#1155)
fix: return 0 from delete() when user cancels operation (#1155) (#1316)
dimitri-yatsenko commentedon Jan 9, 2026
Fixed in #1316