Implemented table.lookup(...), closes #44

* Add pk column if missing from insert
* Implemented table.lookup(...)
This commit is contained in:
Simon Willison 2019-07-23 06:06:59 -07:00 committed by GitHub
commit 5805024316
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 124 additions and 0 deletions

View file

@ -734,3 +734,8 @@ def test_cannot_provide_both_filename_and_memory():
AssertionError, match="Either specify a filename_or_conn or pass memory=True"
):
Database("/tmp/foo.db", memory=True)
def test_creates_id_column(fresh_db):
last_pk = fresh_db.table("cats", pk="id").insert({"name": "barry"}).last_pk
assert [{"name": "barry", "id": last_pk}] == list(fresh_db["cats"].rows)