Tests for .get() NotFoundError

This commit is contained in:
Simon Willison 2019-07-14 21:21:26 -07:00
commit 1445a8ecb5
2 changed files with 24 additions and 1 deletions

View file

@ -410,6 +410,13 @@ class Table:
elif len(pks) > 1:
pk_names = pks
last_pk = pk_values
if len(pk_names) != len(pk_values):
raise NotFoundError(
"Need {} primary key value{}".format(
len(pk_names), "" if len(pk_names) == 1 else "s"
)
)
wheres = ["[{}] = ?".format(pk_name) for pk_name in pk_names]
rows = self.rows_where(" and ".join(wheres), pk_values)
try: