mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Display 0 results, closes #637
This commit is contained in:
parent
fd137da7f8
commit
d3e1c3017e
4 changed files with 53 additions and 26 deletions
|
|
@ -327,3 +327,10 @@ a.not-underlined {
|
||||||
pre.wrapped-sql {
|
pre.wrapped-sql {
|
||||||
white-space: pre-wrap;
|
white-space: pre-wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
p.zero-results {
|
||||||
|
border: 2px solid #ccc;
|
||||||
|
background-color: #eee;
|
||||||
|
padding: 0.5em;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
{% if display_rows %}
|
||||||
<table class="rows-and-columns">
|
<table class="rows-and-columns">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
|
|
@ -26,3 +27,6 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p class="zero-results">0 records</p>
|
||||||
|
{% endif %}
|
||||||
|
|
|
||||||
|
|
@ -73,6 +73,8 @@
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
{% else %}
|
||||||
|
<p class="zero-results">0 results</p>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{% include "_codemirror_foot.html" %}
|
{% include "_codemirror_foot.html" %}
|
||||||
|
|
|
||||||
|
|
@ -1059,3 +1059,17 @@ def test_custom_table_include():
|
||||||
'1 - 2 - <a href="/fixtures/simple_primary_key/1">hello</a> <em>1</em>'
|
'1 - 2 - <a href="/fixtures/simple_primary_key/1">hello</a> <em>1</em>'
|
||||||
"</div>"
|
"</div>"
|
||||||
) == str(Soup(response.text, "html.parser").select_one("div.custom-table-row"))
|
) == 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"))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue