You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Sorted pagination skips or repeats numeric rows without column affinity #3056
Sorted pagination can skip or repeat rows when a SQLite column has no type affinity:
CREATETABLEnumbers (id INTEGERPRIMARY KEY, value);
INSERT INTO numbers VALUES (1,1),(2,2),(3,3),(4,4),(5,5);
With _size=2&_sort=value, the table API returns 1 and 2, then an empty page when following next_url. With _sort_desc=value, following the links repeats 5 and 4. The probe stops after four pages. CREATE TABLE AS SELECT also creates this kind of column, so this affects ordinary derived tables.
The cursor serializes the numeric sort value as text. On the next request SQLite compares a number to a text binding without affinity conversion. INTEGER/REAL columns and text-only controls paginate correctly. Mixed numeric/text columns also lose rows, so guessing a numeric type or casting every value would be wrong.
This is separate from #3054/#3055: these values are unique, and the loss occurs at the cursor value boundary. Preserving the sort scalar's type in the opaque token should address it without changing primary-key URLs.
Reproduced through Datasette.client and real temporary SQLite databases on main 4e70219b, Python 3.13.14 / SQLite 3.53.1. AI assistance was used for investigation and the bounded reproductions.
Activity
Fix traced BLOB cursors and make float cursor tokens URL-safe
simonw commentedon Nov 15, 2026
Demo of the bug: https://lite.datasette.io/?ref=1.0a42&sql=https://gist.github.com/simonw/75ececf61d50e6e8d50f0c150150ee81#/data/scores?_size=2&_sort=score - click next and the second page is empty.
Here's that same page with the bug fixed (running on 1.0a43): https://lite.datasette.io/?ref=1.0a43&sql=https://gist.github.com/simonw/75ececf61d50e6e8d50f0c150150ee81#/data/scores?_size=2&_sort=score
Release 1.0a43
Preserve SQLite sort value types in pagination cursors (simonw#3057)