diff --git a/datasette/app.py b/datasette/app.py index 2dd92841..a6e6f6fc 100644 --- a/datasette/app.py +++ b/datasette/app.py @@ -869,6 +869,8 @@ class TableView(RowTableShared): # Handle ?_page_size=500 page_size = request.raw_args.get('_size') if page_size: + if page_size == 'max': + page_size = self.max_returned_rows try: page_size = int(page_size) if page_size < 0: diff --git a/docs/json_api.rst b/docs/json_api.rst index aa9a914f..bff270f9 100644 --- a/docs/json_api.rst +++ b/docs/json_api.rst @@ -131,9 +131,9 @@ Special table arguments The Datasette table view takes a number of special querystring arguments: -``?_size=1000`` +``?_size=1000`` or ``?_size=max`` Sets a custom page size. This cannot exceed the ``max_returned_rows`` option - passed to ``datasette serve``. + passed to ``datasette serve``. Use ``max`` to get ``max_returned_rows``. ``?_sort=COLUMN`` Sorts the results by the specified column. diff --git a/tests/test_api.py b/tests/test_api.py index 98bb690c..0030e2dc 100644 --- a/tests/test_api.py +++ b/tests/test_api.py @@ -451,6 +451,7 @@ def test_table_with_reserved_word_name(app_client): ('/test_tables/paginated_view.json', 201, 5), ('/test_tables/no_primary_key.json?_size=25', 201, 9), ('/test_tables/paginated_view.json?_size=25', 201, 9), + ('/test_tables/paginated_view.json?_size=max', 201, 3), ('/test_tables/123_starts_with_digits.json', 0, 1), ]) def test_paginate_tables_and_views(app_client_longer_time_limit, path, expected_rows, expected_pages): @@ -458,6 +459,7 @@ def test_paginate_tables_and_views(app_client_longer_time_limit, path, expected_ count = 0 while path: response = app_client_longer_time_limit.get(path, gather_request=False) + assert 200 == response.status count += 1 fetched.extend(response.json['rows']) path = response.json['next_url']