mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-23 01:14:31 +02:00
Fix delete_where() leaving the connection in an open transaction
Table.delete_where() ran its DELETE via a bare execute() with no commit, unlike Table.delete() which wraps in db.atomic(). The connection was left with an open implicit transaction, so the deletion (and all subsequent writes, including later atomic() blocks which switched to savepoint mode) was silently rolled back when the connection closed. Wrap the DELETE in db.atomic() and remove the now-unnecessary atomic() wrapper from the delete_where documentation example. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UnLnhsH25Nnv7LHhekUfPd
This commit is contained in:
parent
f3c012774a
commit
b17c37144e
3 changed files with 21 additions and 3 deletions
|
|
@ -984,8 +984,7 @@ You can delete all records in a table that match a specific WHERE statement usin
|
|||
|
||||
>>> db = sqlite_utils.Database("dogs.db")
|
||||
>>> # Delete every dog with age less than 3
|
||||
>>> with db.atomic():
|
||||
>>> db.table("dogs").delete_where("age < ?", [3])
|
||||
>>> db.table("dogs").delete_where("age < ?", [3])
|
||||
|
||||
Calling ``table.delete_where()`` with no other arguments will delete every row in the table.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue