label_column option in metadata.json - closes #234

This commit is contained in:
Simon Willison 2018-04-22 10:51:43 -07:00
commit f27cabbaf3
No known key found for this signature in database
GPG key ID: 17E2DEA2588B7F52
5 changed files with 73 additions and 3 deletions

View file

@ -524,7 +524,12 @@ class RowTableShared(BaseView):
if table_info and expand_foreign_keys:
foreign_keys = table_info['foreign_keys']['outgoing']
for fk in foreign_keys:
label_column = tables.get(fk['other_table'], {}).get('label_column')
label_column = (
# First look for metadata.json definition:
table_metadata.get('label_column')
# Fall back to label_column from .inspect() detection:
or tables.get(fk['other_table'], {}).get('label_column')
)
if not label_column:
# No label for this FK
fks[fk['column']] = fk['other_table']