mirror of
https://github.com/simonw/sqlite-utils.git
synced 2026-08-01 15:04:11 +02:00
Make square braces only return tables, not views
Breaking change for 4.0: db["name"] now only returns Table objects, never View objects.
This improves type safety since views lack methods like .insert().
Use db.view("view_name") to access views explicitly.
Closes #699
This commit is contained in:
parent
8d74ffc932
commit
c791a31047
6 changed files with 18 additions and 15 deletions
|
|
@ -12,6 +12,7 @@ from sqlite_utils.db import (
|
|||
BadMultiValues,
|
||||
DescIndex,
|
||||
NoTable,
|
||||
NoView,
|
||||
quote_identifier,
|
||||
)
|
||||
from sqlite_utils.plugins import pm, get_plugins
|
||||
|
|
@ -1796,9 +1797,10 @@ def drop_view(path, view, ignore, load_extension):
|
|||
_register_db_for_cleanup(db)
|
||||
_load_extensions(db, load_extension)
|
||||
try:
|
||||
db[view].drop(ignore=ignore)
|
||||
except OperationalError:
|
||||
raise click.ClickException('View "{}" does not exist'.format(view))
|
||||
db.view(view).drop(ignore=ignore)
|
||||
except NoView:
|
||||
if not ignore:
|
||||
raise click.ClickException('View "{}" does not exist'.format(view))
|
||||
|
||||
|
||||
@cli.command()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue