You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Ability to default to hiding the SQL for a canned query #1422
If you do this it should still be possible to view the SQL - which means we need a new parameter. I propose ?_show_sql=1 to over-ride the hidden default.
I think the configuration should use hide_sql: true - looking like this:
databases:
fixtures:
queries:
neighborhood_search:
hide_sql: truesql: |- select neighborhood, facet_cities.name, state from facetable join facet_cities on facetable.city_id = facet_cities.id where neighborhood like '%' || :text || '%' order by neighborhoodtitle: Search neighborhoods
{% if not canned_query %}<inputtype="hidden" name="sql" value="{% if query and query.sql %}{{ query.sql }}{% else %}select * from {{ tables[0].name|escape_sqlite }}{% endif %}">{% endif %}
Activity
simonw commentedon Aug 5, 2021
If you do this it should still be possible to view the SQL - which means we need a new parameter. I propose
?_show_sql=1to over-ride the hidden default.I think the configuration should use
hide_sql: true- looking like this:simonw commentedon Aug 5, 2021
The logic for this is a little bit fiddly, due to the need to switch to using
?_show_sql=1on the link depending on the context.?_show_sql=1?_show_sql=1, show and have hide link linking to URL without?_show_sql=1?_hide_sql=1?_hide_sql=1simonw commentedon Aug 7, 2021
Also need to consider this hidden field - it should pass the
_hide_sqlor_show_sqlparameters depending on the same logic:datasette/datasette/templates/query.html
Lines 47 to 49 in acc2243
New hide_sql canned query option, refs #1422
simonw commentedon Aug 7, 2021
Demo: https://latest.datasette.io/fixtures/neighborhood_search
Documentation: https://docs.datasette.io/en/latest/sql_queries.html#additional-canned-query-options
Release 0.59a0
Publish with 0.59a0 to use hide_sql option
Release 0.59
Release 0.59