diff --git a/datasette/templates/query.html b/datasette/templates/query.html index b6c74883..543561d8 100644 --- a/datasette/templates/query.html +++ b/datasette/templates/query.html @@ -44,7 +44,7 @@
{% if query %}{{ query.sql }}{% endif %}
{% endif %}
{% else %}
-
+ {% if not canned_query %}{% endif %}
{% endif %}
{% if named_parameter_values %}
diff --git a/tests/test_html.py b/tests/test_html.py
index aee6bce1..9f5b99e3 100644
--- a/tests/test_html.py
+++ b/tests/test_html.py
@@ -1238,6 +1238,17 @@ def test_show_hide_sql_query(app_client):
] == [(hidden["name"], hidden["value"]) for hidden in hiddens]
+def test_canned_query_with_hide_has_no_hidden_sql(app_client):
+ # For a canned query the show/hide should NOT have a hidden SQL field
+ # https://github.com/simonw/datasette/issues/1411
+ response = app_client.get("/fixtures/neighborhood_search?_hide_sql=1")
+ soup = Soup(response.body, "html.parser")
+ hiddens = soup.find("form").select("input[type=hidden]")
+ assert [
+ ("_hide_sql", "1"),
+ ] == [(hidden["name"], hidden["value"]) for hidden in hiddens]
+
+
def test_extra_where_clauses(app_client):
response = app_client.get(
"/fixtures/facetable?_where=neighborhood='Dogpatch'&_where=city_id=1"