Can datasette be configured to sort tables using multiple columns by default? #1652
Unanswered
zaneselvans
asked this question in
Q&A
Replies: 1 comment
-
No it can't, but that's a good feature request. Converting this into an issue! |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's easy to tell datasette to sort tables using a single column, as described in the docs:
But is there some way to tell it to sort using a composite key, like you would in an
ORDER BY
clause instead? For example, the way it's being done in this query on our Datasette?The problem here is that by default it's using
rowid
(the SQLite assigned autoincrementing integer key) to order the records, but the table should have a natural composite primary key, but the original database that this data is being migrated from doesn't enforce unique primary keys, so there are dupes, and we don't want to drop those rows, and the records are somehow getting jumbled in the database (therowid
ordering isn't lined up with the expected ordering based on the composite primary key, though it's close) and this jumbling is confusing to users that expect to see the data ordered based on the natural primary key.I've tried setting the
sort
metadata parameter to a list of column names, a tuple of column names, a quoted string of comma-separated column names, a quoted string of a tuple of column names...and they all give me server errors like:
Beta Was this translation helpful? Give feedback.
All reactions