Show error message on bad query, closes #619

pull/1357/head
Simon Willison 2021-06-01 20:59:29 -07:00
rodzic 9552414e1f
commit ea5b237800
2 zmienionych plików z 12 dodań i 2 usunięć

Wyświetl plik

@ -34,8 +34,8 @@
<form class="sql" action="{{ urls.database(database) }}{% if canned_query %}/{{ canned_query }}{% endif %}" method="{% if canned_write %}post{% else %}get{% endif %}">
<h3>Custom SQL query{% if display_rows %} returning {% if truncated %}more than {% endif %}{{ "{:,}".format(display_rows|length) }} row{% if display_rows|length == 1 %}{% else %}s{% endif %}{% endif %}{% if not query_error %} <span class="show-hide-sql">{% if hide_sql %}(<a href="{{ path_with_removed_args(request, {'_hide_sql': '1'}) }}">show</a>){% else %}(<a href="{{ path_with_added_args(request, {'_hide_sql': '1'}) }}">hide</a>){% endif %}</span>{% endif %}</h3>
{% if query_error %}
<p class="message-error">{{ query_error }}</p>
{% if error %}
<p class="message-error">{{ error }}</p>
{% endif %}
{% if not hide_sql %}
{% if editable and allow_execute_sql %}

Wyświetl plik

@ -1402,6 +1402,16 @@ def test_zero_results(app_client, path):
assert 1 == len(soup.select("p.zero-results"))
def test_query_error(app_client):
response = app_client.get("/fixtures?sql=select+*+from+notatable")
html = response.text
assert '<p class="message-error">no such table: notatable</p>' in html
assert (
'<textarea id="sql-editor" name="sql">select * from notatable</textarea>'
in html
)
def test_config_template_debug_on():
with make_app_client(config={"template_debug": True}) as client:
response = client.get("/fixtures/facetable?_context=1")