Skip to content

Commit

Permalink
Fix broken CSV/JSON export on query page, refs #1010
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Oct 10, 2020
1 parent c13d184 commit 9f6dd98
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion datasette/templates/query.html
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ <h3>Query parameters</h3>
</form>

{% if display_rows %}
<p class="export-links">This data as {% for name, url in renderers.items() %}<a href="{{ base_url }}{{ url }}">{{ name }}</a>{{ ", " if not loop.last }}{% endfor %}, <a href="{{ base_url }}{{ url_csv }}">CSV</a></p>
<p class="export-links">This data as {% for name, url in renderers.items() %}<a href="{{ url }}">{{ name }}</a>{{ ", " if not loop.last }}{% endfor %}, <a href="{{ url_csv }}">CSV</a></p>
<table class="rows-and-columns">
<thead>
<tr>
Expand Down
7 changes: 7 additions & 0 deletions tests/test_html.py
Original file line number Diff line number Diff line change
Expand Up @@ -672,6 +672,13 @@ def test_row_json_export_link(app_client):
assert '<a href="/fixtures/simple_primary_key/1.json">json</a>' in response.text


def test_query_json_csv_export_links(app_client):
response = app_client.get("/fixtures?sql=select+1")
assert response.status == 200
assert '<a href="/fixtures.json?sql=select+1">json</a>' in response.text
assert '<a href="/fixtures.csv?sql=select+1&amp;_size=max">CSV</a>' in response.text


def test_csv_json_export_links_include_labels_if_foreign_keys(app_client):
response = app_client.get("/fixtures/facetable")
assert response.status == 200
Expand Down

0 comments on commit 9f6dd98

Please sign in to comment.