Rename ensure_autocommit_off() to ensure_autocommit_on()#776
Merged
Conversation
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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #705.
Database.ensure_autocommit_off()setisolation_level = Noneon the underlyingsqlite3connection, 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 (runningPRAGMA journal_mode=...outside implicit transactions), so this renames the method toensure_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.
sqlite_utils/db.pytest_ensure_autocommit_onverifyingisolation_levelisNoneinside the block and restored afterwards🤖 Generated with Claude Code
📚 Documentation preview 📚: https://sqlite-utils--776.org.readthedocs.build/en/776/