Refactor .update() to use .get()

.pks introspection now returns [rowid] for rowid tables.
This commit is contained in:
Simon Willison 2019-07-28 15:44:33 +03:00
commit e4a11b1815
2 changed files with 20 additions and 30 deletions

View file

@ -98,3 +98,11 @@ def test_guess_foreign_table(fresh_db, column, expected_table_guess):
fresh_db.create_table("authors", {"name": str})
fresh_db.create_table("genre", {"name": str})
assert expected_table_guess == fresh_db["books"].guess_foreign_table(column)
@pytest.mark.parametrize(
"pk,expected", ((None, ["rowid"]), ("id", ["id"]), (["id", "id2"], ["id", "id2"]))
)
def test_pks(fresh_db, pk, expected):
fresh_db["foo"].insert_all([{"id": 1, "id2": 2}], pk=pk)
assert expected == fresh_db["foo"].pks