Hidden tables sqlite1/2/3/4, closes #1587

pull/1610/head
Simon Willison 2022-01-19 20:12:46 -08:00
rodzic cb29119db9
commit 58652dd925
2 zmienionych plików z 15 dodań i 1 usunięć

Wyświetl plik

@ -345,7 +345,9 @@ class Database:
"""
select name from sqlite_master
where rootpage = 0
and sql like '%VIRTUAL TABLE%USING FTS%'
and (
sql like '%VIRTUAL TABLE%USING FTS%'
) or name in ('sqlite_stat1', 'sqlite_stat2', 'sqlite_stat3', 'sqlite_stat4')
"""
)
).rows

Wyświetl plik

@ -1030,3 +1030,15 @@ async def test_db_path(app_client):
# Previously this broke if path was a pathlib.Path:
await datasette.refresh_schemas()
@pytest.mark.asyncio
async def test_hidden_sqlite_stat1_table():
ds = Datasette()
db = ds.add_memory_database("db")
await db.execute_write("create table normal (id integer primary key, name text)")
await db.execute_write("create index idx on normal (name)")
await db.execute_write("analyze")
data = (await ds.client.get("/db.json?_show_hidden=1")).json()
tables = [(t["name"], t["hidden"]) for t in data["tables"]]
assert tables == [("normal", False), ("sqlite_stat1", True)]