From 468d51314adac193e63b3a6ef9d67f0d43501e9b Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 29 Dec 2019 21:31:03 -0800 Subject: [PATCH] test_upsert_compound_primary_key --- tests/test_upsert.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/test_upsert.py b/tests/test_upsert.py index 96f9d0d..9b93f88 100644 --- a/tests/test_upsert.py +++ b/tests/test_upsert.py @@ -14,3 +14,13 @@ def test_upsert_all(fresh_db): {"id": 2, "name": "Nixie", "age": 5}, ] == list(table.rows) assert 2 == table.last_pk + + +def test_upsert_compound_primary_key(fresh_db): + table = fresh_db["table"] + table.upsert_all([{"species": "dog", "id": 1, "name": "Cleo", "age": 4}, {"species": "cat", "id": 1, "name": "Catbag"}], pk=("species", "id")) + table.upsert_all([{"species": "dog", "id": 1, "age": 5}], pk=("species", "id")) + assert [ + {"species": "dog", "id": 1, "name": "Cleo", "age": 5}, + {"species": "cat", "id": 1, "name": "Catbag", "age": None}, + ] == list(table.rows) \ No newline at end of file