mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Avoid error sorting by relationships if related tables are not allowed
Refs #1306
This commit is contained in:
parent
f40d1b99d6
commit
0f41db1ba8
1 changed files with 3 additions and 2 deletions
|
|
@ -78,8 +78,9 @@ class IndexView(BaseView):
|
||||||
# We will be sorting by number of relationships, so populate that field
|
# We will be sorting by number of relationships, so populate that field
|
||||||
all_foreign_keys = await db.get_all_foreign_keys()
|
all_foreign_keys = await db.get_all_foreign_keys()
|
||||||
for table, foreign_keys in all_foreign_keys.items():
|
for table, foreign_keys in all_foreign_keys.items():
|
||||||
count = len(foreign_keys["incoming"] + foreign_keys["outgoing"])
|
if table in tables.keys():
|
||||||
tables[table]["num_relationships_for_sorting"] = count
|
count = len(foreign_keys["incoming"] + foreign_keys["outgoing"])
|
||||||
|
tables[table]["num_relationships_for_sorting"] = count
|
||||||
|
|
||||||
hidden_tables = [t for t in tables.values() if t["hidden"]]
|
hidden_tables = [t for t in tables.values() if t["hidden"]]
|
||||||
visible_tables = [t for t in tables.values() if not t["hidden"]]
|
visible_tables = [t for t in tables.values() if not t["hidden"]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue