kopia lustrzana https://github.com/simonw/datasette
Support nested JSON in metadata.json, closes #2403
rodzic
1f3fb5f96b
commit
9028d7f805
|
@ -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]}'
|
||||
|
|
Ładowanie…
Reference in New Issue