Fix for use_old_upsert branch

Refs https://github.com/simonw/sqlite-utils/pull/653#issuecomment-2864951112
This commit is contained in:
Simon Willison 2025-05-08 20:10:17 -07:00
commit 41497c3210
3 changed files with 52 additions and 44 deletions

View file

@ -1,9 +1,12 @@
from sqlite_utils.db import PrimaryKeyRequired
from sqlite_utils import Database
import pytest
def test_upsert(fresh_db):
table = fresh_db["table"]
@pytest.mark.parametrize("use_old_upsert", (False, True))
def test_upsert(use_old_upsert):
db = Database(memory=True, use_old_upsert=use_old_upsert)
table = db["table"]
table.insert({"id": 1, "name": "Cleo"}, pk="id")
table.upsert({"id": 1, "age": 5}, pk="id", alter=True)
assert list(table.rows) == [{"id": 1, "name": "Cleo", "age": 5}]