table_config instead of table_metadata (#2257)

Table configuration that was incorrectly placed in metadata is now treated as if it was in config.

New await datasette.table_config() method.

Closes #2247
This commit is contained in:
Simon Willison 2024-02-06 21:57:09 -08:00 committed by GitHub
commit 60c6692f68
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 175 additions and 30 deletions

View file

@ -487,13 +487,11 @@ class Database:
)
).rows
]
# Add any from metadata.json
db_metadata = self.ds.metadata(database=self.name)
if "tables" in db_metadata:
# Add any tables marked as hidden in config
db_config = self.ds.config.get("databases", {}).get(self.name, {})
if "tables" in db_config:
hidden_tables += [
t
for t in db_metadata["tables"]
if db_metadata["tables"][t].get("hidden")
t for t in db_config["tables"] if db_config["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