Skip to content

Fix --truncate for empty inserts - #937

Closed
xiexqian-stack wants to merge 1 commit into
simonw:mainfrom
xiexqian-stack:fix/truncate-empty-inserts
Closed

xiexqian-stack wants to merge 1 commit into
simonw:mainfrom
xiexqian-stack:fix/truncate-empty-inserts

Conversation

@xiexqian-stack

@xiexqian-stack xiexqian-stack commented Nov 11, 2026 •

Copy link
Copy Markdown

Fixes #935

insert_all([], truncate=True) and the CLI's insert --truncate returned before the truncate step, leaving existing rows in place. The same happened for an empty generator, a header-only list, an empty JSON array, and a header-only CSV.

The empty-input paths now call delete_where(), which is a no-op when the table does not exist and keeps the existing schema. Non-empty inserts continue to use the same truncate path as before.

Tests added for empty list, empty generator, header-only list, empty JSON via the CLI, and header-only CSV via the CLI.

PYTHONUTF8=1 python -m pytest -q reports 1502 passed, 16 skipped.


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

@simonw

simonw commented Nov 29, 2026

Copy link
Copy Markdown
Owner

Fixed in:

@simonw simonw closed this Nov 29, 2026
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.

Empty --truncate imports leave existing rows in place

2 participants