Fixed bug where metadata.json hidden tables were ignored

pull/443/head
Simon Willison 2019-05-01 17:54:48 -07:00
rodzic e7151ccccf
commit 50d2d1aac9
3 zmienionych plików z 18 dodań i 9 usunięć

Wyświetl plik

@ -205,6 +205,20 @@ class ConnectedDatabase:
""")
).rows
]
# Add any from metadata.json
db_metadata = self.ds.metadata(database=self.name)
if "tables" in db_metadata:
hidden_tables += [
t for t in db_metadata["tables"] if db_metadata["tables"][t].get("hidden")
]
# Also mark as hidden any tables which start with the name of a hidden table
# e.g. "searchable_fts" implies "searchable_fts_content" should be hidden
for table_name in await self.table_names():
for hidden_table in hidden_tables[:]:
if table_name.startswith(hidden_table):
hidden_tables.append(table_name)
continue
return hidden_tables
async def view_names(self):

Wyświetl plik

@ -41,13 +41,6 @@ class IndexView(RenderMixin):
name, lambda conn: detect_fts(conn, table)
),
}
# Also mark as hidden any tables which start with the name of a hidden table
# e.g. "searchable_fts" implies "searchable_fts_content" should be hidden
for t in tables.keys():
for hidden_table in hidden_table_names:
if t == hidden_table or t.startswith(hidden_table):
tables[t]["hidden"] = True
continue
hidden_tables = [t for t in tables.values() if t["hidden"]]
databases.append({

Wyświetl plik

@ -26,8 +26,10 @@ def test_homepage(app_client):
assert d["tables_count"] == 25
assert len(d["tables_truncated"]) == 5
assert d["tables_more"] is True
assert d["hidden_table_rows_sum"] == 5
assert d["hidden_tables_count"] == 4
# 4 hidden FTS tables + no_primary_key (hidden in metadata)
assert d["hidden_tables_count"] == 5
# 201 in no_primary_key, plus 5 in other hidden tables:
assert d["hidden_table_rows_sum"] == 206
assert d["views_count"] == 4