mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-08 09:34:08 +02:00
Fix count_where() raising OperationalError on nonexistent tables
rows_where() and delete_where() already return gracefully when called on a table that does not exist yet; count_where() now does the same by returning 0 instead of propagating OperationalError from SQLite.
This commit is contained in:
parent
fcfccea813
commit
4fd34b85ad
2 changed files with 8 additions and 0 deletions
|
|
@ -96,6 +96,12 @@ def test_count_where(existing_db):
|
|||
assert existing_db.table("foo").count_where("text != :t", {"t": "two"}) == 2
|
||||
|
||||
|
||||
def test_count_where_nonexistent_table(fresh_db):
|
||||
assert fresh_db.table("does_not_exist").count_where() == 0
|
||||
assert fresh_db.table("does_not_exist").count_where("id > ?", [5]) == 0
|
||||
assert fresh_db.table("does_not_exist").count == 0
|
||||
|
||||
|
||||
def test_columns(existing_db):
|
||||
table = existing_db.table("foo")
|
||||
assert [{"name": "text", "type": "TEXT"}] == [
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue