kopia lustrzana https://github.com/simonw/datasette
Hide tables starting with an _, refs #2104
rodzic
a395256c8c
commit
7818e8b9d1
|
@ -469,6 +469,7 @@ class Database:
|
|||
and (
|
||||
sql like '%VIRTUAL TABLE%USING FTS%'
|
||||
) or name in ('sqlite_stat1', 'sqlite_stat2', 'sqlite_stat3', 'sqlite_stat4')
|
||||
or name like '\\_%' escape '\\'
|
||||
"""
|
||||
)
|
||||
).rows
|
||||
|
|
|
@ -40,6 +40,21 @@ The JSON version of this page provides programmatic access to the underlying dat
|
|||
* `fivethirtyeight.datasettes.com/fivethirtyeight.json <https://fivethirtyeight.datasettes.com/fivethirtyeight.json>`_
|
||||
* `global-power-plants.datasettes.com/global-power-plants.json <https://global-power-plants.datasettes.com/global-power-plants.json>`_
|
||||
|
||||
.. _DatabaseView_hidden:
|
||||
|
||||
Hidden tables
|
||||
-------------
|
||||
|
||||
Some tables listed on the database page are treated as hidden. Hidden tables are not completely invisible - they can be accessed through the "hidden tables" link at the bottom of the page. They are hidden because they represent low-level implementation details which are generally not useful to end-users of Datasette.
|
||||
|
||||
The following tables are hidden by default:
|
||||
|
||||
- Any table with a name that starts with an underscore - this is a Datasette convention to help plugins easily hide their own internal tables.
|
||||
- Tables that have been configured as ``"hidden": true`` using :ref:`metadata_hiding_tables`.
|
||||
- ``*_fts`` tables that implement SQLite full-text search indexes.
|
||||
- Tables relating to the inner workings of the SpatiaLite SQLite extension.
|
||||
- ``sqlite_stat`` tables used to store statistics used by the query optimizer.
|
||||
|
||||
.. _TableView:
|
||||
|
||||
Table
|
||||
|
|
|
@ -1018,6 +1018,21 @@ async def test_hidden_sqlite_stat1_table():
|
|||
)
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_hide_tables_starting_with_underscore():
|
||||
ds = Datasette()
|
||||
db = ds.add_memory_database("test_hide_tables_starting_with_underscore")
|
||||
await db.execute_write("create table normal (id integer primary key, name text)")
|
||||
await db.execute_write("create table _hidden (id integer primary key, name text)")
|
||||
data = (
|
||||
await ds.client.get(
|
||||
"/test_hide_tables_starting_with_underscore.json?_show_hidden=1"
|
||||
)
|
||||
).json()
|
||||
tables = [(t["name"], t["hidden"]) for t in data["tables"]]
|
||||
assert tables == [("normal", False), ("_hidden", True)]
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("db_name", ("foo", r"fo%o", "f~/c.d"))
|
||||
async def test_tilde_encoded_database_names(db_name):
|
||||
|
|
Ładowanie…
Reference in New Issue