Repository navigation
Conversation
AI assistance: OpenAI Codex.
atishay-kasliwal
left a comment
There was a problem hiding this comment.
All 3 new test cases fail on main and pass here. tests/test_create.py goes from 219 to 222 passed.
I also ran three rows through the paths that take hash_id_columns, with iter(["code"]) or a generator: insert_all (default and batch_size=1), upsert_all, db.table(..., hash_id_columns=...) then insert_all, and create(..., hash_id_columns=...) then insert_all. On main, the insert paths raise UNIQUE constraint failed: t.id. Here every path gives the three expected hash_record(row, ["code"]) ids, and dict_keys works on both branches.
The upsert_all case on main is worse than the issue says: there's no error, it just leaves 2 rows out of 3, because the 2nd and 3rd rows hash to the same id and the 3rd overwrites the 2nd. The new test only covers insert_all, so an upsert_all case might be worth adding, since that's where the bug lost data silently.
Fixes #991
Snapshot one-shot
hash_id_columnsinputs before using them to hash rows or saving them as defaults. The selected columns are then available for every row and for later inserts using the same table defaults.The regression tests cover an iterator passed directly to
insert_all(), an iterator passed todb.table(), and an iterator passed totable.create(). All 12 targeted hash ID tests passed in both SQLite connection modes on Python 3.13 and Windows.OpenAI Codex assisted with reproducing the bug, writing the change and regression tests, and preparing this draft.