Skip to content

Rename ensure_autocommit_off() to ensure_autocommit_on()#776

Merged
simonw merged 1 commit into
mainfrom
issue-705-ensure-autocommit-on
Jul 6, 2026
Merged

Rename ensure_autocommit_off() to ensure_autocommit_on()#776
simonw merged 1 commit into
mainfrom
issue-705-ensure-autocommit-on

Conversation

@simonw

@simonw simonw commented Jul 6, 2026

Copy link
Copy Markdown
Owner

Closes #705.

Database.ensure_autocommit_off() set isolation_level = None on the underlying sqlite3 connection, which per the Python docs puts the driver into autocommit mode — the opposite of what the name and docstring claimed. The behavior itself was correct for its call sites (running PRAGMA journal_mode=... outside implicit transactions), so this renames the method to ensure_autocommit_on() and rewrites the docstring to describe what it actually does.

This is a breaking change for 4.0 — the old name is removed with no deprecated alias. Documented in the changelog (Unreleased → Breaking changes) and in the 3.x → 4.0 upgrade guide.

  • Renamed method and updated its three internal call sites in sqlite_utils/db.py
  • Added test_ensure_autocommit_on verifying isolation_level is None inside the block and restored afterwards
  • Full test suite passes: 1200 passed, 16 skipped

🤖 Generated with Claude Code


📚 Documentation preview 📚: https://sqlite-utils--776.org.readthedocs.build/en/776/

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>
@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 95.24%. Comparing base (07b603e) to head (6df6da1).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #776   +/-   ##
=======================================
  Coverage   95.24%   95.24%           
=======================================
  Files           9        9           
  Lines        3597     3597           
=======================================
  Hits         3426     3426           
  Misses        171      171           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@simonw
simonw merged commit 50938ee into main Jul 6, 2026
105 of 107 checks passed
@simonw
simonw deleted the issue-705-ensure-autocommit-on branch July 6, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ensure_autocommit_off() is confusing

1 participant