mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-07-25 10:24:32 +02:00
table.count_where() method, closes #305
This commit is contained in:
parent
5ec6686153
commit
4823aff4c3
4 changed files with 45 additions and 10 deletions
|
|
@ -132,7 +132,7 @@ def test_uses_counts_after_enable_counts(counts_db_path):
|
|||
assert db["foo"].count == 1
|
||||
assert logged == [
|
||||
("select name from sqlite_master where type = 'view'", None),
|
||||
("select count(*) from [foo]", None),
|
||||
("select count(*) from [foo]", []),
|
||||
]
|
||||
logged.clear()
|
||||
assert not db.use_counts_table
|
||||
|
|
|
|||
|
|
@ -52,7 +52,14 @@ def test_views(fresh_db):
|
|||
|
||||
|
||||
def test_count(existing_db):
|
||||
assert 3 == existing_db["foo"].count
|
||||
assert existing_db["foo"].count == 3
|
||||
assert existing_db["foo"].count_where() == 3
|
||||
assert existing_db["foo"].execute_count() == 3
|
||||
|
||||
|
||||
def test_count_where(existing_db):
|
||||
assert existing_db["foo"].count_where("text != ?", ["two"]) == 2
|
||||
assert existing_db["foo"].count_where("text != :t", {"t": "two"}) == 2
|
||||
|
||||
|
||||
def test_columns(existing_db):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue