simonw / simonw/sqlite-utils

rows_where() and delete_where() fail to throw errors against non-existent tables (fix in v5)

Open
#841 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

breaking-change-for-v5 bug
Dominant language
Python
Stars
2.2k
Forks
172
Avg merge
9m
Merged PRs (30d)
1

Description

Pointed out in:

  • #840

Currently this runs without throwing errors:

python -c 'import sqlite_utils
db = sqlite_utils.Database(memory=True)
print(list(db.table("does_not_exist").rows_where()))                                          
db.table("does_not_exist").delete_where()' 

But this does raise an error:

python -c 'import sqlite_utils
db = sqlite_utils.Database(memory=True)
print(db.table("does_not_exist").count_where())'

Raises:

sqlite3.OperationalError: no such table: does_not_exist

#840 proposed fixing count_where() to return 0. I think the fix is that those other two methods should raise an error, but since this would break compatibility I'm going to hold it for a future v5 version.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Locate the Python implementations of rows_where(), delete_where(), and count_where(), then reproduce the missing-table behavior shown in the issue. Compare how these methods handle nonexistent tables; done means rows_where() and delete_where() raise the appropriate SQLite error, with coverage for both cases, while accounting for the stated v5 compatibility target.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, sqlite
Domain
databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.