.update(...) with no update argument sets last_pk

This commit is contained in:
Simon Willison 2019-07-28 17:59:52 +03:00
commit bc9c4db34b
2 changed files with 19 additions and 0 deletions

View file

@ -64,3 +64,20 @@ def test_update_alter(fresh_db):
"int_col": -10,
}
] == list(table.rows)
def test_update_with_no_values_sets_last_pk(fresh_db):
table = fresh_db.table("dogs", pk="id")
table.insert_all([{
"id": 1,
"name": "Cleo",
}, {
"id": 2,
"name": "Pancakes"
}])
table.update(1)
assert 1 == table.last_pk
table.update(2)
assert 2 == table.last_pk
with pytest.raises(NotFoundError):
table.update(3)