mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-10-27 02:37:13 +01:00
fix: raise NoTable from rows_where() and delete_where() for non-existent tables
rows_where() silently returned an empty iterator and delete_where() silently returned self when called on a table that does not exist. This masked bugs in callers that passed a wrong table name. Both methods now raise NoTable (matching the behaviour of count_where() and duplicate()), as planned for the v5 release.
This commit is contained in:
parent
56dd09702f
commit
5c6eb9a4ec
3 changed files with 15 additions and 2 deletions
|
|
@ -147,3 +147,9 @@ def test_pks_and_rows_where_compound_pk_declaration_order(fresh_db):
|
|||
fresh_db.table("t").insert({"a": "A", "b": "B"})
|
||||
pks_and_rows = list(fresh_db.table("t").pks_and_rows_where())
|
||||
assert pks_and_rows == [(("A", "B"), {"b": "B", "a": "A"})]
|
||||
|
||||
|
||||
def test_rows_where_nonexistent_table_raises(fresh_db):
|
||||
from sqlite_utils.db import NoTable
|
||||
with pytest.raises(NoTable):
|
||||
list(fresh_db.table("does_not_exist").rows_where())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue