mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Fix bug where compound foreign keys produced broken links, closes #1098
This commit is contained in:
parent
e800ffcf7c
commit
deb0be4ae5
6 changed files with 88 additions and 29 deletions
|
|
@ -237,6 +237,8 @@ def test_database_page(app_client):
|
|||
"foreign_key_with_label",
|
||||
"foreign_key_with_blank_label",
|
||||
"foreign_key_with_no_label",
|
||||
"foreign_key_compound_pk1",
|
||||
"foreign_key_compound_pk2",
|
||||
],
|
||||
"primary_keys": ["pk"],
|
||||
"count": 2,
|
||||
|
|
@ -1637,6 +1639,8 @@ def test_expand_label(app_client):
|
|||
"foreign_key_with_label": {"value": "1", "label": "hello"},
|
||||
"foreign_key_with_blank_label": "3",
|
||||
"foreign_key_with_no_label": "1",
|
||||
"foreign_key_compound_pk1": "a",
|
||||
"foreign_key_compound_pk2": "b",
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1821,24 +1825,28 @@ def test_common_prefix_database_names(app_client_conflicting_database_names):
|
|||
assert db_name == data["database"]
|
||||
|
||||
|
||||
def test_null_foreign_keys_are_not_expanded(app_client):
|
||||
def test_null_and_compound_foreign_keys_are_not_expanded(app_client):
|
||||
response = app_client.get(
|
||||
"/fixtures/foreign_key_references.json?_shape=array&_labels=on"
|
||||
)
|
||||
assert [
|
||||
assert response.json == [
|
||||
{
|
||||
"pk": "1",
|
||||
"foreign_key_with_label": {"value": "1", "label": "hello"},
|
||||
"foreign_key_with_blank_label": {"value": "3", "label": ""},
|
||||
"foreign_key_with_no_label": {"value": "1", "label": "1"},
|
||||
"foreign_key_compound_pk1": "a",
|
||||
"foreign_key_compound_pk2": "b",
|
||||
},
|
||||
{
|
||||
"pk": "2",
|
||||
"foreign_key_with_label": None,
|
||||
"foreign_key_with_blank_label": None,
|
||||
"foreign_key_with_no_label": None,
|
||||
"foreign_key_compound_pk1": None,
|
||||
"foreign_key_compound_pk2": None,
|
||||
},
|
||||
] == response.json
|
||||
]
|
||||
|
||||
|
||||
def test_inspect_file_used_for_count(app_client_immutable_and_inspect_file):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue