mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
New hide_sql canned query option, refs #1422
This commit is contained in:
parent
b7037f5ece
commit
66e143c76e
6 changed files with 111 additions and 14 deletions
|
|
@ -674,7 +674,7 @@ The main focus of this release is a major upgrade to the :ref:`plugin_register_o
|
|||
* Visually distinguish float and integer columns - useful for figuring out why order-by-column might be returning unexpected results. (:issue:`729`)
|
||||
* The :ref:`internals_request`, which is passed to several plugin hooks, is now documented. (:issue:`706`)
|
||||
* New ``metadata.json`` option for setting a custom default page size for specific tables and views, see :ref:`metadata_page_size`. (:issue:`751`)
|
||||
* Canned queries can now be configured with a default URL fragment hash, useful when working with plugins such as `datasette-vega <https://github.com/simonw/datasette-vega>`__, see :ref:`canned_queries_default_fragment`. (:issue:`706`)
|
||||
* Canned queries can now be configured with a default URL fragment hash, useful when working with plugins such as `datasette-vega <https://github.com/simonw/datasette-vega>`__, see :ref:`canned_queries_options`. (:issue:`706`)
|
||||
* Fixed a bug in ``datasette publish`` when running on operating systems where the ``/tmp`` directory lives in a different volume, using a backport of the Python 3.8 ``shutil.copytree()`` function. (:issue:`744`)
|
||||
* Every plugin hook is now covered by the unit tests, and a new unit test checks that each plugin hook has at least one corresponding test. (:issue:`771`, :issue:`773`)
|
||||
|
||||
|
|
|
|||
|
|
@ -187,14 +187,28 @@ You can alternatively provide an explicit list of named parameters using the ``"
|
|||
order by neighborhood
|
||||
title: Search neighborhoods
|
||||
|
||||
.. _canned_queries_default_fragment:
|
||||
.. _canned_queries_options:
|
||||
|
||||
Setting a default fragment
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Additional canned query options
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Additional options can be specified for canned queries in the YAML or JSON configuration.
|
||||
|
||||
hide_sql
|
||||
++++++++
|
||||
|
||||
Canned queries default to displaying their SQL query at the top of the page. If the query is extremely long you may want to hide it by default, with a "show" link that can be used to make it visible.
|
||||
|
||||
Add the ``"hide_sql": true`` option to hide the SQL query by default.
|
||||
|
||||
fragment
|
||||
++++++++
|
||||
|
||||
Some plugins, such as `datasette-vega <https://github.com/simonw/datasette-vega>`__, can be configured by including additional data in the fragment hash of the URL - the bit that comes after a ``#`` symbol.
|
||||
|
||||
You can set a default fragment hash that will be included in the link to the canned query from the database index page using the ``"fragment"`` key:
|
||||
You can set a default fragment hash that will be included in the link to the canned query from the database index page using the ``"fragment"`` key.
|
||||
|
||||
This example demonstrates both ``fragment`` and ``hide_sql``:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
|
|
@ -204,7 +218,8 @@ You can set a default fragment hash that will be included in the link to the can
|
|||
"queries": {
|
||||
"neighborhood_search": {
|
||||
"sql": "select neighborhood, facet_cities.name, state\nfrom facetable join facet_cities on facetable.city_id = facet_cities.id\nwhere neighborhood like '%' || :text || '%' order by neighborhood;",
|
||||
"fragment": "fragment-goes-here"
|
||||
"fragment": "fragment-goes-here",
|
||||
"hide_sql": true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue