Skip to content

Fix ad hoc query form action - #2877

Open
RamiNoodle733 wants to merge 2 commits into
simonw:mainfrom
RamiNoodle733:fix/query-form-action-2487
Open

Fix ad hoc query form action#2877
RamiNoodle733 wants to merge 2 commits into
simonw:mainfrom
RamiNoodle733:fix/query-form-action-2487

Conversation

@RamiNoodle733

Copy link
Copy Markdown

Fixes #2487.

The ad hoc query page currently submits its SQL form to the database root, while the initial query form uses the dedicated /-/query route. This updates query.html so non-stored queries consistently submit to /<database>/-/query, while preserving the existing stored-query action.

Includes a focused regression test asserting the rendered ad hoc query form targets /fixtures/-/query.

I could not run the test suite locally in this automation environment because the local runtime does not have a usable GitHub checkout/network path, so CI is the verification path for this change.

Copilot AI lite review requested due to automatic review settings August 11, 2026 16:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Updates the ad hoc SQL query form in the query results template so it submits back to the dedicated /-/query route (matching the initial database page behavior), addressing the broken “Run SQL” action reported in #2487.

Changes:

  • Update query.html so non-stored queries submit to /<database>/-/query instead of the database root.
  • Add a regression test asserting the rendered ad hoc query form action is /fixtures/-/query.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
datasette/templates/query.html Adjusts the SQL form action URL for ad hoc queries to target /-/query.
tests/test_query_form_action.py Adds a regression test checking the ad hoc query form action points at the query route.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.



@pytest.mark.asyncio
async def test_ad_hoc_query_form_posts_to_query_route(ds_client):
{% block description_source_license %}{% include "_description_source_license.html" %}{% endblock %}

<form class="sql core" action="{{ urls.database(database) }}{% if stored_query %}/{{ stored_query }}{% endif %}" method="{% if stored_query_write %}post{% else %}get{% endif %}" data-parameters-url="{{ urls.database(database) }}/-/query/parameters">
<form class="sql core" action="{{ urls.database(database) }}{% if stored_query %}/{{ stored_query }}{% else %}/-/query{% endif %}" method="{% if stored_query_write %}post{% else %}get{% endif %}" data-parameters-url="{{ urls.database(database) }}/-/query/parameters">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Clicking 'Run SQL' from extneded query.html page results in URL not found error

2 participants