Fix count_where() raising OperationalError on nonexistent tables - #840
Closed
ikatyal2110 wants to merge 1 commit into
Closed
Fix count_where() raising OperationalError on nonexistent tables#840ikatyal2110 wants to merge 1 commit into
ikatyal2110 wants to merge 1 commit into
Conversation
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.
simonw
reviewed
Aug 13, 2026
|
|
||
| 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 |
Owner
There was a problem hiding this comment.
This doesn't feel right to me. I prefer the existing behavior of raising an error.
Owner
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
rows_where() and delete_where() both return gracefully when called on a table that does not yet exist, but count_where() propagates an OperationalError from SQLite instead of returning 0. This adds an existence check at the top of count_where() to make its behaviour consistent with the rest of the API. Adds a test covering count_where() and the count property on a nonexistent table.
Generated by Claude Code
📚 Documentation preview 📚: https://sqlite-utils--840.org.readthedocs.build/en/840/