Skip to content

test: verify hash_record key-order independence - #983

Open
janmejai2002 wants to merge 1 commit into
simonw:mainfrom
janmejai2002:test-gap/hash-record-key-order
Open

janmejai2002 wants to merge 1 commit into
simonw:mainfrom
janmejai2002:test-gap/hash-record-key-order

Conversation

@janmejai2002

@janmejai2002 janmejai2002 commented Dec 1, 2026 •

Copy link
Copy Markdown

Condition

sqlite_utils.utils.hash_record passes sort_keys=True to json.dumps so that a record's SHA-1 digest—used for hash_id primary keys—is independent of dictionary key insertion order.

Test Gap

tests/test_utils.py::test_hash_record only tests dictionaries whose keys (name, twitter, age when filtered via keys=(name, twitter)) are already in alphabetical insertion order. Changing sort_keys=True to sort_keys=False in hash_record previously passed the entire test suite without failure.

Changes

  • Added tests/test_utils.py::test_hash_record_key_order to assert that utils.hash_record({twitter: CleoPaws, name: Cleo}) matches the sorted-key SHA-1 digest and equals utils.hash_record({name: Cleo, twitter: CleoPaws}).
  • Test-only change; no production code modified.

Verification

  • pytest tests/test_utils.py -k test_hash_record_key_order -v: 1 passed, 19 deselected
  • pytest -q (full suite on Windows, without SpatiaLite): 1630 passed, 18 skipped

Detected with cordis-verify

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.

1 participant