Raise ValueError instead of assert for conflicting insert_all() options
insert_all() validates two mutually-exclusive argument pairs — pk=/hash_id= and ignore=/replace= — with bare assert statements:
assert not (hash_id and pk), "Use either pk= or hash_id="
...
assert not (ignore and replace), "Use either ignore=True or replace=True, not both"
Two problems:
assertstatements are stripped when Python runs under-O/-OO, so on optimized deployments these checks vanish entirely and a contradictory call (e.g.insert_all(rows, pk="id", hash_id="hash")) silently proceeds instead of being rejected.- When they do fire they raise
AssertionError, which is inconsistent with the neighbouring validation a couple of lines above that raisesPrimaryKeyRequired/ValueErrorfor the same kind of argument problem.
This replaces both asserts with explicit ValueError raises (same messages) and adds regression tests for the two conflicts. No behaviour change for valid calls.
Full test suite passes (1042 passed, 16 skipped); black/flake8 clean.
📚 Documentation preview 📚: https://sqlite-utils--753.org.readthedocs.build/en/753/
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.
Fixed in the latest RC.