Skip to content
Permalink
Browse files

Fix pagination when sorted by expanded foreign key

Closes #489
  • Loading branch information...
simonw committed May 28, 2019
1 parent f069950 commit 9c58d048ec4af8a35b680a5654c2a18985704f8b
Showing with 4 additions and 0 deletions.
  1. +2 −0 datasette/views/table.py
  2. +2 −0 tests/test_api.py
@@ -629,6 +629,8 @@ class TableView(RowTableShared):
# If there's a sort or sort_desc, add that value as a prefix
if (sort or sort_desc) and not is_view:
prefix = rows[-2][sort or sort_desc]
if isinstance(prefix, dict) and "value" in prefix:
prefix = prefix["value"]
if prefix is None:
prefix = "$null"
else:
@@ -753,6 +753,8 @@ def test_table_with_reserved_word_name(app_client):
("/fixtures/123_starts_with_digits.json", 0, 1),
# Ensure faceting doesn't break pagination:
("/fixtures/compound_three_primary_keys.json?_facet=pk1", 1001, 21),
# Paginating while sorted by an expanded foreign key should work
("/fixtures/roadside_attraction_characteristics.json?_size=2&_sort=attraction_id&_labels=on", 5, 3),
],
)
def test_paginate_tables_and_views(app_client, path, expected_rows, expected_pages):

0 comments on commit 9c58d04

Please sign in to comment.
You can’t perform that action at this time.