Skip to content

Fix #705: Clarify ensure_autocommit_off() naming and documentation#708

Open
RamiNoodle733 wants to merge 2 commits intosimonw:mainfrom
RamiNoodle733:fix-autocommit-docstring
Open

Fix #705: Clarify ensure_autocommit_off() naming and documentation#708
RamiNoodle733 wants to merge 2 commits intosimonw:mainfrom
RamiNoodle733:fix-autocommit-docstring

Conversation

@RamiNoodle733
Copy link

@RamiNoodle733 RamiNoodle733 commented Feb 7, 2026

Fixes #705

The function name ensure_autocommit_off() was confusing because it sets isolation_level = None, which actually ENABLES autocommit mode in SQLite, not disables it.

Changes

  • Added new ensure_autocommit_on() method with correct name and accurate docstring explaining that isolation_level = None enables autocommit mode
  • Deprecated ensure_autocommit_off() - kept as alias for backwards compatibility with DeprecationWarning
  • Updated internal usages (enable_wal(), disable_wal()) to use the new method name
  • Added warnings import for the deprecation notice

Backwards Compatibility

Existing code using ensure_autocommit_off() will continue to work but will emit a DeprecationWarning directing users to the new method name.


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

Test User added 2 commits February 7, 2026 14:12
When inserting a CSV file that contains only a header row (no data rows),
the --detect-types option would crash with an AssertionError because it
tried to transform a table that didn't exist.

This fix adds a check to ensure the table exists before attempting to
apply type transformations. The fix is applied in two places:
1. insert_upsert_implementation() for the insert command
2. memory() command for CSV/TSV files

Added test case: test_insert_csv_headers_only
The function name ensure_autocommit_off() was confusing because it sets
isolation_level = None, which actually ENABLES autocommit mode in SQLite,
not disables it.

Changes:
- Add new ensure_autocommit_on() method with correct name and docstring
- Keep ensure_autocommit_off() as deprecated alias for backwards compatibility
- Update internal usages (enable_wal(), disable_wal()) to use new method
- Add warnings import for deprecation notice
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