Skip to content

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

Description

@jcouto

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. :)

Activity

  1. dimitri-yatsenko commented on Mar 20, 2024

    @dimitri-yatsenko
    Member

    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.

  2. jcouto commented on Mar 20, 2024

    @jcouto
    Author

    I agree, thanks.

  3. github-actions commented on Mar 14, 2025

    @github-actions

    This issue is stale because it has been open for 45 days with no activity.

  4. added
    staleIndicates issues, pull requests, or discussions are inactive
    on Mar 14, 2025
  5. removed
    staleIndicates issues, pull requests, or discussions are inactive
    on Jan 9, 2026
  6. dimitri-yatsenko commented on Jan 9, 2026

    @dimitri-yatsenko
    Member

    Fixed in #1316

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

Metadata

Metadata

Labels

enhancementIndicates new improvements

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions