mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-09-08 01:24:20 +02: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
|
|
@ -2160,7 +2160,7 @@ class Queryable:
|
|||
:param offset: Integer for SQL offset
|
||||
"""
|
||||
if not self.exists():
|
||||
return
|
||||
raise NoTable(f"Table {self.name} does not exist")
|
||||
sql = f"select {select} from {quote_identifier(self.name)}"
|
||||
if where is not None:
|
||||
sql += " where " + where
|
||||
|
|
@ -4105,7 +4105,7 @@ class Table(Queryable):
|
|||
:param analyze: Set to ``True`` to run ``ANALYZE`` after the rows have been deleted.
|
||||
"""
|
||||
if not self.exists():
|
||||
return self
|
||||
raise NoTable(f"Table {self.name} does not exist")
|
||||
sql = f"delete from {quote_identifier(self.name)}"
|
||||
if where is not None:
|
||||
sql += " where " + where
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue