mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
.json?_labels=1 to expand foreign keys, refs #233
Output looks something like this:
{
"rowid": 233,
"TreeID": 121240,
"qLegalStatus": {
"value" 2,
"label": "Private"
}
"qSpecies": {
"value": 16,
"label": "Sycamore"
}
"qAddress": "91 Commonwealth Ave",
...
}
This commit is contained in:
parent
5bda4a477c
commit
825b8a2557
4 changed files with 107 additions and 3 deletions
|
|
@ -1096,6 +1096,35 @@ def test_suggest_facets_off():
|
|||
).json["suggested_facets"]
|
||||
|
||||
|
||||
def test_expand_labels(app_client):
|
||||
response = app_client.get(
|
||||
"/test_tables/facetable.json?_shape=object&_labels=1&_size=2"
|
||||
"&neighborhood__contains=c"
|
||||
)
|
||||
assert {
|
||||
"2": {
|
||||
"pk": 2,
|
||||
"planet_int": 1,
|
||||
"state": "CA",
|
||||
"city_id": {
|
||||
"value": 1,
|
||||
"label": "San Francisco"
|
||||
},
|
||||
"neighborhood": "Dogpatch"
|
||||
},
|
||||
"13": {
|
||||
"pk": 13,
|
||||
"planet_int": 1,
|
||||
"state": "MI",
|
||||
"city_id": {
|
||||
"value": 3,
|
||||
"label": "Detroit"
|
||||
},
|
||||
"neighborhood": "Corktown"
|
||||
}
|
||||
} == response.json
|
||||
|
||||
|
||||
@pytest.mark.parametrize('path,expected_cache_control', [
|
||||
("/test_tables/facetable.json", "max-age=31536000"),
|
||||
("/test_tables/facetable.json?_ttl=invalid", "max-age=31536000"),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue