Fix ad hoc query form action - #2877
Open
RamiNoodle733 wants to merge 2 commits into
Open
Conversation
There was a problem hiding this comment.
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.htmlso non-stored queries submit to/<database>/-/queryinstead 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"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2487.
The ad hoc query page currently submits its SQL form to the database root, while the initial query form uses the dedicated
/-/queryroute. This updatesquery.htmlso 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.