-
-
Notifications
You must be signed in to change notification settings - Fork 703
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
500 error if sorted by a column not in the ?_col= list #1773
Comments
Traceback:
That's this code here: datasette/datasette/views/table.py Lines 631 to 645 in 7af67b5
|
So the problem here is that in generating the Possible fixes:
Not sure which solution is more elegant. I think it might be the second one. |
So code would look something like this: try:
prefix = rows[-2][sort or sort_desc]
except KeyError:
# Didn't select sort/sort_desc column - look up value by primary key instead
primary_key = rows[-2]["pk"] # But more complex than this
prefix = (await db.execute("select * from {table} where pk = ?", [primary_key])).first_value() |
For example: https://latest.datasette.io/fixtures/sortable?_sort_desc=sortable&_col=sortable_with_nulls
That's
?_sort_desc=sortable&_col=sortable_with_nulls
The text was updated successfully, but these errors were encountered: