mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
don't hide virtual table, hide shadow tables.
This commit is contained in:
parent
bf953628bb
commit
751abbcc57
4 changed files with 116 additions and 51 deletions
|
|
@ -389,6 +389,29 @@ async def test_database_page(ds_client):
|
|||
},
|
||||
"private": False,
|
||||
},
|
||||
{
|
||||
"name": "searchable_fts",
|
||||
"columns": [
|
||||
"text1",
|
||||
"text2",
|
||||
"name with . and spaces",
|
||||
]
|
||||
+ (
|
||||
[
|
||||
"searchable_fts",
|
||||
"docid",
|
||||
"__langid",
|
||||
]
|
||||
if supports_table_xinfo()
|
||||
else []
|
||||
),
|
||||
"primary_keys": [],
|
||||
"count": 2,
|
||||
"hidden": False,
|
||||
"fts_table": "searchable_fts",
|
||||
"foreign_keys": {"incoming": [], "outgoing": []},
|
||||
"private": False,
|
||||
},
|
||||
{
|
||||
"name": "searchable_tags",
|
||||
"columns": ["searchable_id", "tag"],
|
||||
|
|
@ -525,29 +548,6 @@ async def test_database_page(ds_client):
|
|||
"foreign_keys": {"incoming": [], "outgoing": []},
|
||||
"private": False,
|
||||
},
|
||||
{
|
||||
"name": "searchable_fts",
|
||||
"columns": [
|
||||
"text1",
|
||||
"text2",
|
||||
"name with . and spaces",
|
||||
]
|
||||
+ (
|
||||
[
|
||||
"searchable_fts",
|
||||
"docid",
|
||||
"__langid",
|
||||
]
|
||||
if supports_table_xinfo()
|
||||
else []
|
||||
),
|
||||
"primary_keys": [],
|
||||
"count": 2,
|
||||
"hidden": True,
|
||||
"fts_table": "searchable_fts",
|
||||
"foreign_keys": {"incoming": [], "outgoing": []},
|
||||
"private": False,
|
||||
},
|
||||
{
|
||||
"name": "searchable_fts_docsize",
|
||||
"columns": ["docid", "size"],
|
||||
|
|
|
|||
|
|
@ -39,13 +39,14 @@ def test_homepage(app_client_two_attached_databases):
|
|||
assert "extra database" == h2.text.strip()
|
||||
counts_p, links_p = h2.find_all_next("p")[:2]
|
||||
assert (
|
||||
"2 rows in 1 table, 5 rows in 4 hidden tables, 1 view" == counts_p.text.strip()
|
||||
"4 rows in 2 tables, 3 rows in 3 hidden tables, 1 view" == counts_p.text.strip()
|
||||
)
|
||||
# We should only show visible, not hidden tables here:
|
||||
table_links = [
|
||||
{"href": a["href"], "text": a.text.strip()} for a in links_p.findAll("a")
|
||||
]
|
||||
assert [
|
||||
{"href": r"/extra+database/searchable_fts", "text": "searchable_fts"},
|
||||
{"href": r"/extra+database/searchable", "text": "searchable"},
|
||||
{"href": r"/extra+database/searchable_view", "text": "searchable_view"},
|
||||
] == table_links
|
||||
|
|
|
|||
|
|
@ -664,3 +664,45 @@ async def test_in_memory_databases_forbid_writes(app_client):
|
|||
# Using db.execute_write() should work:
|
||||
await db.execute_write("create table foo (t text)")
|
||||
assert await db.table_names() == ["foo"]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hidden_tables(app_client):
|
||||
ds = app_client.ds
|
||||
db = ds.add_database(Database(ds, is_memory=True, is_mutable=True))
|
||||
assert await db.hidden_table_names() == []
|
||||
await db.execute("create virtual table f using fts5(a)")
|
||||
assert await db.hidden_table_names() == [
|
||||
'f_config',
|
||||
'f_content',
|
||||
'f_data',
|
||||
'f_docsize',
|
||||
'f_idx',
|
||||
]
|
||||
|
||||
await db.execute("create virtual table r using rtree(id, amin, amax)")
|
||||
assert await db.hidden_table_names() == [
|
||||
'f_config',
|
||||
'f_content',
|
||||
'f_data',
|
||||
'f_docsize',
|
||||
'f_idx',
|
||||
'r_node',
|
||||
'r_parent',
|
||||
'r_rowid'
|
||||
]
|
||||
|
||||
await db.execute("create table _hideme(_)")
|
||||
assert await db.hidden_table_names() == [
|
||||
'_hideme',
|
||||
'f_config',
|
||||
'f_content',
|
||||
'f_data',
|
||||
'f_docsize',
|
||||
'f_idx',
|
||||
'r_node',
|
||||
'r_parent',
|
||||
'r_rowid'
|
||||
]
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue