mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-20 07:24:23 +02:00
Rename ensure_autocommit_off() to ensure_autocommit_on(), closes #705
The ensure_autocommit_off() context manager was misleadingly named: it sets isolation_level = None on the underlying sqlite3 connection, which puts the driver INTO autocommit mode (no implicit transactions) - the opposite of what the name and docstring claimed. The behavior was always correct for its call sites, which need autocommit to run PRAGMA statements like journal_mode=wal. This renames the method to ensure_autocommit_on() with an accurate docstring, updates the three internal call sites, adds tests, and documents the rename in the changelog and the 3.x to 4.0 upgrading guide. The old name is removed outright since 4.0 permits breaking changes. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
07b603e562
commit
6df6da1a8e
4 changed files with 27 additions and 7 deletions
|
|
@ -49,6 +49,17 @@ def test_disable_wal_inside_transaction_raises(db_path_tmpdir):
|
|||
assert [r["id"] for r in db["test"].rows] == [1]
|
||||
|
||||
|
||||
def test_ensure_autocommit_on(db_path_tmpdir):
|
||||
db, path, tmpdir = db_path_tmpdir
|
||||
previous_isolation_level = db.conn.isolation_level
|
||||
assert previous_isolation_level is not None
|
||||
with db.ensure_autocommit_on():
|
||||
# isolation_level of None means driver-level autocommit mode
|
||||
assert db.conn.isolation_level is None
|
||||
# Restored afterwards
|
||||
assert db.conn.isolation_level == previous_isolation_level
|
||||
|
||||
|
||||
def test_enable_wal_noop_inside_transaction_is_allowed(db_path_tmpdir):
|
||||
# Calling enable_wal() when WAL is already enabled is a no-op,
|
||||
# so it is fine inside a transaction
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue