Skip to content

Respect _size on arbitrary SQL query pages#2720

Open
MatrixHackin wants to merge 1 commit into
simonw:mainfrom
MatrixHackin:fix-query-size-arbitrary-sql
Open

Respect _size on arbitrary SQL query pages#2720
MatrixHackin wants to merge 1 commit into
simonw:mainfrom
MatrixHackin:fix-query-size-arbitrary-sql

Conversation

@MatrixHackin
Copy link
Copy Markdown

Summary

This fixes #1200 by making _size= work on arbitrary SQL query pages.
Previously, URLs such as:

/fixtures/-/query?sql=select+*+from+compound_three_primary_keys&_size=10

ignored _size=10 and displayed all rows up to max_returned_rows. But the query result with many figures may cause rendering pressure.This change:

  • parses and validates _size in QueryView
  • supports _size=max
  • limits arbitrary SQL query results according to _size
  • marks results as truncated when _size hides additional rows
  • persists _size in the query form using a hidden input

Tests

conda run -n datasette-issue1200 pytest -q \
  tests/test_api.py::test_custom_sql_size \
  tests/test_api.py::test_custom_sql_size_validation \
  tests/test_html.py::test_query_size \
  tests/test_api.py::test_custom_sql \
  tests/test_html.py::test_query_json_csv_export_links

Result:

7 passed

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.

?_size=10 option for the arbitrary query page would be useful

1 participant