Increase height of non-JS textarea to fit query

Closes #1786
pull/1789/head
Simon Willison 2022-08-18 09:06:02 -07:00
rodzic 481eb96d85
commit a3e6f1b167
2 zmienionych plików z 4 dodań i 5 usunięć

Wyświetl plik

@ -45,7 +45,8 @@
{% endif %}
{% if not hide_sql %}
{% if editable and allow_execute_sql %}
<p><textarea id="sql-editor" name="sql">{% if query and query.sql %}{{ query.sql }}{% else %}select * from {{ tables[0].name|escape_sqlite }}{% endif %}</textarea></p>
<p><textarea id="sql-editor" name="sql"{% if query and query.sql %} style="height: {{ query.sql.split("\n")|length + 2 }}em"{% endif %}
>{% if query and query.sql %}{{ query.sql }}{% else %}select * from {{ tables[0].name|escape_sqlite }}{% endif %}</textarea></p>
{% else %}
<pre id="sql-query">{% if query %}{{ query.sql }}{% endif %}</pre>
{% endif %}

Wyświetl plik

@ -695,10 +695,8 @@ 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
)
assert '<textarea id="sql-editor" name="sql" style="height: 3em' in html
assert ">select * from notatable</textarea>" in html
assert "0 results" not in html