Skip to content

Conversation

@dimitri-yatsenko
Copy link
Member

Summary

Fixes delete() to return 0 when the user cancels the operation at the prompt.

Problem

When a user answered "no" to "Commit deletes?", the transaction was correctly rolled back, but delete() still returned the count of rows that would have been deleted.

>>> result = MyTable().delete()
Deleting 5 rows from `schema`.`my_table`
Commit deletes? [yes, No]: no
Delete cancelled
>>> print(result)
5  # Should be 0!

Fix

Reset delete_count to 0 when the delete is cancelled:

else:
    if transaction:
        self.connection.cancel_transaction()
    if prompt:
        logger.warning("Delete cancelled")
    delete_count = 0  # Added this line
return delete_count

Behavior

Scenario Before After
Delete committed N (correct) N (unchanged)
Delete cancelled N (wrong) 0 (fixed)
Nothing to delete 0 (correct) 0 (unchanged)

Closes

🤖 Generated with Claude Code

When a user answers "no" to "Commit deletes?", the transaction is
rolled back but delete() still returned the count of rows that would
have been deleted. This was unintuitive - if nothing was deleted,
the return value should be 0.

Now delete() returns 0 when:
- User cancels at the prompt
- Nothing to delete (already worked correctly)

Fixes #1155

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@github-actions github-actions bot added bug Indicates an unexpected problem or unintended behavior enhancement Indicates new improvements labels Jan 9, 2026
@dimitri-yatsenko dimitri-yatsenko merged commit 3f5b237 into pre/v2.0 Jan 9, 2026
8 checks passed
@dimitri-yatsenko dimitri-yatsenko deleted the fix/1155 branch January 9, 2026 21:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Indicates an unexpected problem or unintended behavior enhancement Indicates new improvements

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants