Repository navigation
Reject scalar JSON before inserting rows - #979
Open
xudukongju wants to merge 1 commit into
Open
xudukongju wants to merge 1 commit into
xudukongju wants to merge 1 commit into
Conversation
Preserve valid empty snapshots while rejecting an invalid top-level value. Fixes simonw#978.
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.
Fixes #978. Keeps the valid empty-snapshot behavior from #935/#936.
Plain JSON imports now reject a top-level scalar before handing the input to the row iterator. An empty JSON string no longer reaches the
--truncateempty-input path. Arrays and single objects still work; this does not change JSON Lines, CSV, TSV, or the existing per-row conversion of arrays.Verified with disposable SQLite databases and a separate PyPI 4.2.2 install: a scalar string previously exited 0 and removed the old row. The same input now returns a Click error and preserves the old row, schema and index; a valid replacement succeeds afterward. A valid empty array still clears the rows. For users staying on 4.2.2, checking the JSON root shape on the same input file before calling
insert --truncatealso avoided the loss in this test.Added regression tests covering scalar input,
--flatten, retry with valid input, and existing--convertbehavior. Local checks: 1,637 passed / 17 skipped; 110 affected tests also passed with--sqlite-autocommit. Black and flake8 passed for the changed Python files.OpenAI Codex (GPT-6.2 Sol) assisted with investigation, implementation, testing and this description. The change does not claim malformed-input atomicity for streamed batches.
📚 Documentation preview 📚: https://sqlite-utils--979.org.readthedocs.build/en/979/