mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
parent
e47117ce1d
commit
a9b9d42791
2 changed files with 48 additions and 1 deletions
|
|
@ -778,14 +778,34 @@ class Datasette:
|
|||
if column_names and len(column_names) == 2 and 'id' in column_names:
|
||||
label_column = [c for c in column_names if c != 'id'][0]
|
||||
tables[table] = {
|
||||
'name': table,
|
||||
'columns': column_names,
|
||||
'count': count,
|
||||
'label_column': label_column,
|
||||
'hidden': False,
|
||||
}
|
||||
|
||||
foreign_keys = get_all_foreign_keys(conn)
|
||||
for table, info in foreign_keys.items():
|
||||
tables[table]['foreign_keys'] = info
|
||||
|
||||
# Mark tables 'hidden' if they relate to FTS virtual tables
|
||||
fts_tables = [
|
||||
r['name']
|
||||
for r in conn.execute(
|
||||
'''
|
||||
select name from sqlite_master
|
||||
where rootpage = 0
|
||||
and sql like '%VIRTUAL TABLE%USING FTS%'
|
||||
'''
|
||||
)
|
||||
]
|
||||
for t in tables.keys():
|
||||
for fts_table in fts_tables:
|
||||
if t == fts_table or t.startswith(fts_table):
|
||||
tables[t]['hidden'] = True
|
||||
continue
|
||||
|
||||
self._inspect[name] = {
|
||||
'hash': m.hexdigest(),
|
||||
'file': str(path),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue