Don't explain an explain even in the demo, refs #2293

This commit is contained in:
Simon Willison 2024-03-05 18:14:55 -08:00
commit 4d24bf6b34
3 changed files with 13 additions and 8 deletions

View file

@ -954,6 +954,8 @@ async def test_hook_table_actions(ds_client, table_or_view):
"/fixtures/pragma_cache_size",
"/fixtures?sql=explain+PRAGMA+cache_size%3B",
),
# Don't attempt to explain an explain
("/fixtures?sql=explain+select+1", None),
),
)
async def test_hook_query_actions(ds_client, path, expected_url):
@ -967,7 +969,10 @@ async def test_hook_query_actions(ds_client, path, expected_url):
response = await ds_client.get(path)
assert response.status_code == 200
links = get_table_actions_links(response.text)
assert links == [{"label": "Explain this query", "href": expected_url}]
if expected_url is None:
assert links == []
else:
assert links == [{"label": "Explain this query", "href": expected_url}]
@pytest.mark.asyncio