Skip to content

Commit

Permalink
skip over "queries" blocks when processing database-level metadata it…
Browse files Browse the repository at this point in the history
…ems (#2386)
  • Loading branch information
asg017 authored Aug 16, 2024
1 parent 53a8ae1 commit 0dd41ef
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ async def apply_metadata_json(self):
# step 2: database-level metadata
for dbname, db in self._metadata_local.get("databases", {}).items():
for key, value in db.items():
if key == "tables":
if key in ("tables", "queries"):
continue
await self.set_database_metadata(dbname, key, value)

Expand Down
20 changes: 20 additions & 0 deletions tests/test_internals_datasette.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,3 +173,23 @@ async def test_get_permission(ds_client):
# And test KeyError
with pytest.raises(KeyError):
ds.get_permission("missing-permission")


@pytest.mark.asyncio
async def test_apply_metadata_json():
ds = Datasette(
metadata={
"databases": {
"legislators": {
"tables": {"offices": {"summary": "office address or sumtin"}},
"queries": {
"millenntial_represetatives": {
"summary": "Social media accounts for current legislators"
}
},
}
}
},
)
await ds.invoke_startup()
assert (await ds.client.get("/")).status_code == 200

0 comments on commit 0dd41ef

Please sign in to comment.