mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-01 06:54:22 +02:00
db.table() only returns tables, added db.view()
* db.table() only returns tables, added db.view(), closes #657 * Massive documentation update for db.table() Refs #656
This commit is contained in:
parent
d892d2ae49
commit
094b010fd8
6 changed files with 276 additions and 229 deletions
|
|
@ -8,6 +8,8 @@ from sqlite_utils.db import (
|
|||
ForeignKey,
|
||||
Table,
|
||||
View,
|
||||
NoTable,
|
||||
NoView,
|
||||
)
|
||||
from sqlite_utils.utils import hash_record, sqlite3
|
||||
import collections
|
||||
|
|
@ -1367,3 +1369,14 @@ def test_create_strict(fresh_db, strict):
|
|||
table = fresh_db["t"]
|
||||
table.create({"id": int}, strict=strict)
|
||||
assert table.strict == strict or not fresh_db.supports_strict
|
||||
|
||||
|
||||
def test_bad_table_and_view_exceptions(fresh_db):
|
||||
fresh_db.table("t").insert({"id": 1}, pk="id")
|
||||
fresh_db.create_view("v", "select * from t")
|
||||
with pytest.raises(NoTable) as ex:
|
||||
fresh_db.table("v")
|
||||
assert ex.value.args[0] == "Table v is actually a view"
|
||||
with pytest.raises(NoView) as ex2:
|
||||
fresh_db.view("t")
|
||||
assert ex2.value.args[0] == "View t does not exist"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue