-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
Bug: Sort by column with NULL in next_page URL #216
Comments
Yikes, definitely a bug. |
So there are two tricky problems to solve here:
|
Relevant code: Lines 828 to 832 in 904f1c7
|
I could use
|
I think the correct SQL is this: https://datasette-issue-189-demo-3.now.sh/salaries-7859114-7859114?sql=select+rowid%2C+*+from+%5B2017+Maryland+state+salaries%5D%0D%0Awhere+%28middle_initial+is+not+null+or+%28middle_initial+is+null+and+rowid+%3E+%3Ap0%29%29%0D%0Aorder+by+middle_initial+limit+101&p0=391
Though this will also need to be taken into account for #198 |
But what would that SQL look like for |
Here's where that SQL gets constructed at the moment: Lines 761 to 771 in 10a34f9
|
Weird... tests are failing in Travis, despite passing on my local machine. https://travis-ci.org/simonw/datasette/builds/367423706 |
Still failing. This is very odd. |
I'm reverting this out of master until I can figure out why the tests are failing. |
Here's the test that's failing: Lines 437 to 470 in 59a3aa8
I got Travis to spit out the
I've managed to replicate the bug in production! I created a test database like this:
Then deployed that database like so:
And... if you click "next" on this page https://datasette-issue-216-pagination.now.sh/sortable-5679797/sortable?_sort_desc=sortable_with_nulls five times you get back 250 results, when you should only get back 201. |
The version that I deployed which exhibits the bug is running SQLite The version that I have running locally which does NOT exhibit the bug is running SQLite |
... which is VERY surprising, because |
This is the SQL that returns differing results in production and on my laptop: https://datasette-issue-216-pagination.now.sh/sortable-5679797?sql=select+%2A+from+sortable+where+%28sortable_with_nulls+is+null+and+%28%28pk1+%3E+%3Ap0%29%0A++or%0A%28pk1+%3D+%3Ap0+and+pk2+%3E+%3Ap1%29%29%29+order+by+sortable_with_nulls+desc+limit+51&p0=b&p1=t
I think that Sure enough, changing the query to this one returns the same results across both environments:
|
Reverted commit 5364fa7 (where I removed the code that didn't work). Added primary keys to order-by clause for sorting to get tests to pass
Fixed! |
Copy-pasting from #189 (comment), since that issue is closed:
I think I found a bug. I tried to sort by middle initial in my salaries set, and many middle initials are null. The
next_url
gets set by Datasette to:http://localhost:8001/salaries-d3a5631/2017+Maryland+state+salaries?_next=None%2C391&_sort=middle_initial
But then None is interpreted literally and it tries to find a name with the middle initial "None" and ends up skipping ahead to O on page 2.
The text was updated successfully, but these errors were encountered: