upsert_all() now works with not_null - refs #538

This commit is contained in:
Simon Willison 2023-05-08 12:24:10 -07:00
commit 2376c452a5
2 changed files with 27 additions and 5 deletions

View file

@ -28,6 +28,16 @@ def test_upsert_all_single_column(fresh_db):
assert table.pks == ["name"]
def test_upsert_all_not_null(fresh_db):
# https://github.com/simonw/sqlite-utils/issues/538
fresh_db["comments"].upsert_all(
[{"id": 1, "name": "Cleo"}],
pk="id",
not_null=["name"],
)
assert list(fresh_db["comments"].rows) == [{"id": 1, "name": "Cleo"}]
def test_upsert_error_if_no_pk(fresh_db):
table = fresh_db["table"]
with pytest.raises(PrimaryKeyRequired):