-
-
Notifications
You must be signed in to change notification settings - Fork 693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Keyset pagination doesn't work correctly for compound primary keys #190
Comments
This is because the SQL we are using here is:
This is incorrect. The correct SQL syntax (according to the example on https://www.sqlite.org/rowvalue.html#scrolling_window_queries ) is:
BUT... this uses "row values" syntax which was only added to SQLite in version 3.15.0 in October 2016: https://sqlite.org/changes.html#version_3_15_0 The version on https://datasette-issue-190-compound-pks.now.sh/compound-pks-9aafe8f?sql=select+sqlite_version%28%29%3B is 3.8.7.1 from October 2014. |
Without row values syntax, the necessary SQL to retrieve the next page after
This article was useful for figuring this out: https://use-the-index-luke.com/sql/partial-results/fetch-next-page |
Here's how I generated the table for testing this with 3 compound primary keys:
|
Here's the SQL for a next page with three compound primary keys:
|
Interestingly, in deploying a copy of the database to demonstrate this final bug fix I had to use the
This is because |
Fixed! https://datasette-issue-190-compound-pks-second-fix.now.sh/compound-pks-8e99805/compound_three_primary_keys?_next=b%2Cx%2Cd&content__contains=d now correctly shows |
Consider https://datasette-issue-190-compound-pks.now.sh/compound-pks-9aafe8f/compound_primary_key
The next= link is to
d,v
:https://datasette-issue-190-compound-pks.now.sh/compound-pks-9aafe8f/compound_primary_key?_next=d%2Cv
But that page starts with:
The next key in the sequence should be
d,w
. Also we should return the full a-z of the ones that start with the letter e - in this example we only returne-w
,e-x
,e-y
ande-z
The text was updated successfully, but these errors were encountered: