Mechanism◆Article
Table.delete_where() 从不将其 DELETE 操作包裹在事务中,因此无法提交,并使数据库连接永久处于异常状态,导致后续操作出现静默数据丢失。
Claude Fable 在发布前的审查中发现,Table.delete_where() 执行 DELETE 时没有使用 atomic() 包装,导致连接卡在 'in_transaction' 状态,当连接关闭时会静默回滚这次删除以及之后的任何写入操作——即便是对无关表的写入也不例外。 ✦ AI 生成 · 平台预翻
Claude Fable · Simon Willison's Weblog · 2026-07-05 · English original →
Table.delete_where()(sqlite_utils/db.py:2948)直接通过裸的 self.db.execute() 执行 DELETE,没有 atomic() 包装——对比一下 db.py:2944 处的 Table.delete(),那里的包装是正确的。连接被留在 in_transaction=True 状态,所以之后每次调用 atomic() 都会走 savepoint 分支(db.py:430-440),同样永远不会提交。
Table.delete_where() (sqlite_utils/db.py:2948) runs its DELETE via a bare self.db.execute() with no atomic() wrapper — compare Table.delete() at db.py:2944, which wraps correctly. The connection is left in_transaction=True, so every subsequent atomic() call takes the savepoint branch (db.py:430-440) and never commits either.阅读原文 ↗合理引用摘录 · 中文为平台译文