Repository navigation
Insert API tests for primary key edge cases, plus two fixes - #3081
Merged
Merged
Conversation
Tests cover integer, text and compound primary keys, rowid-only tables and WITHOUT ROWID tables. Writing them turned up two bugs, fixed here: - Inserting with "row" or "return": true into a WITHOUT ROWID table failed with "no such column: rowid" - Rows returned from a table with no primary key did not include the rowid, unlike the upsert API Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3081 +/- ##
=====================================
Coverage 0.00% 0.00%
=====================================
Files 79 79
Lines 13974 13988 +14
=====================================
- Misses 13974 13988 +14 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
simonw
added a commit
that referenced
this pull request
Nov 23, 2026
…upgrade guide sections Release notes for the null, empty string and binary primary key work (#3112), the SpatiaLite KNN count fix (#1611), the insert API fixes (#3081) and the first column facet on views (#2810), which landed without any. The summary paragraph now mentions primary keys and view filters. New upgrade guide sections for datasette.urls.modify(), keyword-only arguments, format_bytes(), TestClient and primary key values, linked from their changelog entries. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
simonw
added a commit
that referenced
this pull request
Nov 23, 2026
Refs #1048, #1342, #1479, #1553, #1611, #1627, #1630, #1671, #1674, #1822, #1841, #1873, #1914, #1919, #1973, #2045, #2073, #2145, #2253, #2356, #2419, #2713, #2805, #2807, #2810, #2826, #2942, #2967, #3070, #3074, #3075, #3078, #3079, #3081, #3082, #3083, #3084, #3085, #3087, #3088, #3089, #3090, #3091, #3092, #3093, #3097, #3098, #3099, #3100, #3101, #3102, #3103, #3104, #3105, #3106, #3107, #3108, #3109, #3111, #3112, #3113, #3115
This was referenced Nov 23, 2026
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.
Refs:
Claude Code
Adds
test_insert_primary_key_edge_cases, a parametrized test that runs a sequence of/-/insertrequests against each kind of table and checks the status, the returned rows and the final table contents:rowidonly): with and without an explicitrowidWITHOUT ROWID, with single and compound primary keysEach covers
"row","rows"with"return": true, primary key conflicts, and"ignore"/"replace"where they work.Bugs fixed
Writing the tests turned up two bugs, both fixed in this PR:
WITHOUT ROWIDtables could not return inserted rows. Any insert using"row"(which always returns) or"return": truefailed withno such column: rowidand inserted nothing, because rows were fetched back byrowid. These tables now fetch rows back by primary key.rowid, so a client could not tell which row it had created. They now include it, matching the upsert API and the table JSON. This is an addition to the response and is noted in the JSON API docs.Found but not fixed
NULLkey. For example{"row": {"title": "x"}}againstcreate table t (id text primary key, title text)returns 201 and storesid = null. Those rows then hit Rows with a primary key ofnullor empty string cannot be edited/deleted/viewed #2805. I have not pinned this in a test, since rejecting it is a behaviour decision that belongs with Rows with a primary key ofnullor empty string cannot be edited/deleted/viewed #2805 and Ensure all created primary keys are not null #2807."ignore": truefails onWITHOUT ROWIDtables when the row already exists, withno such column: rowid. This comes fromsqlite-utils:Table.insert(..., ignore=True)runsselect rowid from ...to find the existing row. The test leaves that case out.I used "Refs" not "Closes" because of the first of those.
🤖 Generated with Claude Code