diff --git a/datasette/static/app.css b/datasette/static/app.css index 34eb122c..d7cf6334 100644 --- a/datasette/static/app.css +++ b/datasette/static/app.css @@ -327,3 +327,10 @@ a.not-underlined { pre.wrapped-sql { white-space: pre-wrap; } + +p.zero-results { + border: 2px solid #ccc; + background-color: #eee; + padding: 0.5em; + font-style: italic; +} diff --git a/datasette/templates/_table.html b/datasette/templates/_table.html index c7a72253..42c37c55 100644 --- a/datasette/templates/_table.html +++ b/datasette/templates/_table.html @@ -1,28 +1,32 @@ -
- {% if not column.sortable %}
- {{ column.name }}
- {% else %}
- {% if column.name == sort %}
- {{ column.name }} ▼
+{% if display_rows %}
+
|
+ {% endfor %}
+ ||
|---|---|---|
| {{ cell.value }} | + {% endfor %} +
0 records
+{% endif %} diff --git a/datasette/templates/query.html b/datasette/templates/query.html index 34fa78a5..f10ff000 100644 --- a/datasette/templates/query.html +++ b/datasette/templates/query.html @@ -73,6 +73,8 @@ {% endfor %} +{% else %} +0 results
{% endif %} {% include "_codemirror_foot.html" %} diff --git a/tests/test_html.py b/tests/test_html.py index 3b331f38..db73da18 100644 --- a/tests/test_html.py +++ b/tests/test_html.py @@ -1059,3 +1059,17 @@ def test_custom_table_include(): '1 - 2 - hello 1' "" ) == str(Soup(response.text, "html.parser").select_one("div.custom-table-row")) + + +@pytest.mark.parametrize( + "path", + [ + "/fixtures?sql=select+*+from+[123_starts_with_digits]", + "/fixtures/123_starts_with_digits", + ], +) +def test_zero_results(app_client, path): + response = app_client.get(path) + soup = Soup(response.text, "html.parser") + assert 0 == len(soup.select("table")) + assert 1 == len(soup.select("p.zero-results"))