mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Support nested JSON in metadata.json, closes #2403
This commit is contained in:
parent
1f3fb5f96b
commit
9028d7f805
2 changed files with 9 additions and 3 deletions
|
|
@ -450,7 +450,10 @@ class Datasette:
|
|||
for key in self._metadata_local or {}:
|
||||
if key == "databases":
|
||||
continue
|
||||
await self.set_instance_metadata(key, self._metadata_local[key])
|
||||
value = self._metadata_local[key]
|
||||
if not isinstance(value, str):
|
||||
value = json.dumps(value)
|
||||
await self.set_instance_metadata(key, value)
|
||||
|
||||
# step 2: database-level metadata
|
||||
for dbname, db in self._metadata_local.get("databases", {}).items():
|
||||
|
|
|
|||
|
|
@ -183,13 +183,16 @@ async def test_apply_metadata_json():
|
|||
"legislators": {
|
||||
"tables": {"offices": {"summary": "office address or sumtin"}},
|
||||
"queries": {
|
||||
"millenntial_represetatives": {
|
||||
"millennial_representatives": {
|
||||
"summary": "Social media accounts for current legislators"
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
"weird_instance_value": {"nested": [1, 2, 3]},
|
||||
},
|
||||
)
|
||||
await ds.invoke_startup()
|
||||
assert (await ds.client.get("/")).status_code == 200
|
||||
value = (await ds.get_instance_metadata()).get("weird_instance_value")
|
||||
assert value == '{"nested": [1, 2, 3]}'
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue