Repository navigation
Honor truncate for empty imports - #936
Merged
Merged
Conversation
atishay-kasliwal
left a comment
There was a problem hiding this comment.
Empty truncate works for me through both the API and the CLI. One gap with analyze.
| first_record = next(records_iter) | ||
| except StopIteration: | ||
| if truncate: | ||
| return self.delete_where() |
There was a problem hiding this comment.
insert_all([], truncate=True, analyze=True) (and --truncate --analyze) skips the ANALYZE, so on a 50 row table sqlite_stat1 still says 50 10 after the delete, while truncating to one row updates it. self.delete_where(analyze=analyze) here and on line 4802 clears it, and the test suite still passes.
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
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:
Empty input currently returns before
truncate=Truecan clear the table. This applies truncation to empty iterables and header-only list input, using the existingdelete_where()helper. Nonempty imports keep their current behavior.Adds library and CLI regressions for empty replacements, schema/index preservation, missing tables, no-truncate calls, and malformed input. Both API and CLI docs now describe empty snapshots.
Tested locally on Python 3.13.14 / SQLite 3.53.1:
pytest -vandpytest --sqlite-autocommiteach passed 1,516 tests, with 16 skips. Black, flake8, mypy, Cog, codespell, and a strict Sphinx HTML build passed. SpatiaLite, compiledext.c, pandas/numpy, and the full CI matrix were not tested.AI assistance was used to investigate, implement, and test this change.
📚 Documentation preview 📚: https://sqlite-utils--936.org.readthedocs.build/en/936/