?_size=max option, closes #249

distinct-column-values
Simon Willison 2018-05-04 15:03:40 -03:00
rodzic bb87cf8730
commit d4da4c92c8
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 17E2DEA2588B7F52
3 zmienionych plików z 6 dodań i 2 usunięć

Wyświetl plik

@ -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:

Wyświetl plik

@ -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.

Wyświetl plik

@ -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']