home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

31 rows where issue = 309471814 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: created_at (date), updated_at (date)

user 2

  • simonw 29
  • carlmjohnson 2

author_association 2

  • OWNER 29
  • NONE 2

issue 1

  • Ability to sort (and paginate) by column · 31 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
381429213 https://github.com/simonw/datasette/issues/189#issuecomment-381429213 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM4MTQyOTIxMw== carlmjohnson 222245 2018-04-15T18:54:22Z 2018-04-15T18:54:22Z NONE

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.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379830529 https://github.com/simonw/datasette/issues/189#issuecomment-379830529 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTgzMDUyOQ== simonw 9599 2018-04-09T17:28:47Z 2018-04-09T17:28:47Z OWNER

Another demo: https://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9/congress-age%2Fcongress-terms

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379803864 https://github.com/simonw/datasette/issues/189#issuecomment-379803864 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTgwMzg2NA== simonw 9599 2018-04-09T16:02:09Z 2018-04-09T16:02:09Z OWNER

This is now released in Datasette 0.15 https://github.com/simonw/datasette/releases/tag/0.15

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379791047 https://github.com/simonw/datasette/issues/189#issuecomment-379791047 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTc5MTA0Nw== carlmjohnson 222245 2018-04-09T15:23:45Z 2018-04-09T15:23:45Z NONE

Awesome!

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379634425 https://github.com/simonw/datasette/issues/189#issuecomment-379634425 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTYzNDQyNQ== simonw 9599 2018-04-09T05:16:02Z 2018-04-09T05:16:02Z OWNER

I've merged this into master.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379608977 https://github.com/simonw/datasette/issues/189#issuecomment-379608977 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTYwODk3Nw== simonw 9599 2018-04-09T02:22:59Z 2018-04-09T02:22:59Z OWNER

Here's a demo of the new clickable column headers: https://datasette-issue-189-demo-3.now.sh/salaries-7859114-7859114/2017+Maryland+state+salaries?_search=university&_sort_desc=last_name

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379603156 https://github.com/simonw/datasette/issues/189#issuecomment-379603156 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTYwMzE1Ng== simonw 9599 2018-04-09T01:41:22Z 2018-04-09T01:41:22Z OWNER

Actually I think I always want nulls last when ordering asc, nulls first when ordering desc.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379602690 https://github.com/simonw/datasette/issues/189#issuecomment-379602690 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTYwMjY5MA== simonw 9599 2018-04-09T01:37:03Z 2018-04-09T01:37:03Z OWNER

I'm going to split the following out into separate tickets:

  • Ability to sort by multiple columns e.g. ?_sort=name&sort_desc=age&_sort=height
  • Ability to specify nulls last e.g. ?_sort_desc_nulls_last=age
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379602339 https://github.com/simonw/datasette/issues/189#issuecomment-379602339 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTYwMjMzOQ== simonw 9599 2018-04-09T01:33:26Z 2018-04-09T01:33:26Z OWNER

Small bug: "201 rows where sorted by sortable_with_nulls" shouldn't have the word "where" in it.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379595274 https://github.com/simonw/datasette/issues/189#issuecomment-379595274 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU5NTI3NA== simonw 9599 2018-04-09T00:24:37Z 2018-04-09T00:29:46Z OWNER

Another demo: https://datasette-issue-189-demo-2.now.sh/salaries-7859114-7859114/2017+Maryland+state+salaries?_search=university&_sort_desc=annual_salary

https://datasette-issue-189-demo-2.now.sh/salaries-7859114-7859114/2017+Maryland+state+salaries?_search=university&last_name__exact=JOHNSON&_sort_desc=annual_salary

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379594529 https://github.com/simonw/datasette/issues/189#issuecomment-379594529 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU5NDUyOQ== simonw 9599 2018-04-09T00:15:03Z 2018-04-09T00:15:03Z OWNER

Demo: senator tweets ordered by number of replies:

https://datasette-issue-189-demo.now.sh/fivethirtyeight-2628db9/twitter-ratio%2Fsenators?_sort_desc=replies

Page 2 (note that since Senators retweet things there are tweets with the same text/number-of-replies but retweeted by different senators that span the page break): https://datasette-issue-189-demo.now.sh/fivethirtyeight-2628db9/twitter-ratio%2Fsenators?_next=8556%2C121799&_sort_desc=replies

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379592393 https://github.com/simonw/datasette/issues/189#issuecomment-379592393 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU5MjM5Mw== simonw 9599 2018-04-08T23:45:42Z 2018-04-08T23:46:31Z OWNER

Actually next page SQL when sorting looks more like this:

select rowid, * from [alcohol-consumption/drinks] where "country" like :p0 and ( beer_servings > 111 or (beer_servings = 111 and rowid > 190) ) order by beer_servings, rowid limit 101

The next page after row 190 with sortable value 111 should show either records that are greater than 111 or records that match 111 but have a greater primary key than the last one seen.

https://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9?sql=select+rowid%2C+*+from+%5Balcohol-consumption%2Fdrinks%5D%0D%0Awhere+%22country%22+like+%3Ap0%0D%0Aand+%28%0D%0A++++beer_servings+%3E+111%0D%0A++++or+%28beer_servings+%3D+111+and+rowid+%3E+190%29%0D%0A%29%0D%0Aorder+by+beer_servings%2C+rowid+limit+101&p0=%25a%25

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379591062 https://github.com/simonw/datasette/issues/189#issuecomment-379591062 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU5MTA2Mg== simonw 9599 2018-04-08T23:23:12Z 2018-04-08T23:23:12Z OWNER

To break this up into smaller units, the first implementation of this will only support a single _sort or _sort_desc querystring parameter.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379557982 https://github.com/simonw/datasette/issues/189#issuecomment-379557982 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU1Nzk4Mg== simonw 9599 2018-04-08T15:16:49Z 2018-04-08T15:16:49Z OWNER

A note about views: a view cannot be paginated using keyset pagination because records returned from a view don't have a primary key - so there's no way to reliably distinguish between _next= records when the sorted column has duplicates with the same value.

Datasette already takes this into account: views are paginated using offset/limit instead. We can continue to do that even for views that have been sorted using a _sort parameter.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379556774 https://github.com/simonw/datasette/issues/189#issuecomment-379556774 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU1Njc3NA== simonw 9599 2018-04-08T14:59:05Z 2018-04-08T14:59:05Z OWNER

A common problem with keyset pagination is that it can distort the "total number of rows" logic - every time you navigate to a further page the total rows count can decrease due to the extra arguments in the where clause. The filtered_table_rows value (see #194) calculated using count_sql currently has this problem.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
379555484 https://github.com/simonw/datasette/issues/189#issuecomment-379555484 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3OTU1NTQ4NA== simonw 9599 2018-04-08T14:39:57Z 2018-04-08T14:39:57Z OWNER

I'm going to combine the code for explicit sorting with the existing code for _next= pagination - so even tables without an explicit sort order will run through the same code since they are ordered and paginated by primary key.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377547265 https://github.com/simonw/datasette/issues/189#issuecomment-377547265 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzU0NzI2NQ== simonw 9599 2018-03-30T15:16:43Z 2018-03-30T15:16:43Z OWNER

I think this is the right incantation for a "next" link: https://datasette-column-sort-wip.now.sh/sortable-4bbaa6f?sql=select+*+from+sortable%0D%0Awhere+sortable+%3C%3D+94%0D%0Aand+%28%0D%0A++%28pk1+%3E+%27d%27%29%0D%0A++or%0D%0A++%28pk1+%3D+%27d%27+and+pk2+%3E+%27w%27%29%0D%0A%29%0D%0Aorder+by+sortable+desc%2C+pk1%2C+pk2%0D%0Alimit+7

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377546510 https://github.com/simonw/datasette/issues/189#issuecomment-377546510 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzU0NjUxMA== simonw 9599 2018-03-30T15:13:11Z 2018-03-30T15:13:11Z OWNER

Pushed some work-in-progress with failing unit tests here: https://github.com/simonw/datasette/commit/2f8359c6f25768805431c80c74e5ec4213c2b2a6

Here's a demo: https://datasette-column-sort-wip.now.sh/sortable-4bbaa6f/sortable?_sort=sortable - note that the _sort_desc and _sort_nulls_last options aren't done yet, plus it doesn't correctly paginate (the _next tokens do not yet take sorting into account).

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377462334 https://github.com/simonw/datasette/issues/189#issuecomment-377462334 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzQ2MjMzNA== simonw 9599 2018-03-30T07:06:21Z 2018-03-30T07:06:21Z OWNER

Maybe the answer here is that anything that's encoded in the next token is treated as >= with the exception of columns known to be primary keys, which are treated as >

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377460127 https://github.com/simonw/datasette/issues/189#issuecomment-377460127 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzQ2MDEyNw== simonw 9599 2018-03-30T06:51:29Z 2018-03-30T06:51:52Z OWNER

The problem is that our _next= pagination currently works based on a > - but for this case a >= for the value is needed combined with a > on the tie-breaker (which would be the rowid column).

So I think this is the right SQL:

select rowid, * from [nfl-wide-receivers/advanced-historical] where career_ranypa >= -6.331167749 and rowid > 2736 order by case when career_ranypa is null then 1 else 0 end, career_ranypa, rowid limit 11

https://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9?sql=select+rowid%2C+*+from+%5Bnfl-wide-receivers%2Fadvanced-historical%5D%0D%0Awhere+career_ranypa+%3E%3D+-6.331167749+and+rowid+%3E+2736%0D%0Aorder+by+case+when+career_ranypa+is+null+then+1+else+0+end%2C+career_ranypa%2C+rowid+limit+11

But how do I encode a _next token that means ">= X and > Y"?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377459579 https://github.com/simonw/datasette/issues/189#issuecomment-377459579 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzQ1OTU3OQ== simonw 9599 2018-03-30T06:47:52Z 2018-03-30T06:47:52Z OWNER

I'm not entirely sure how to get _next= pagination working against sorted collections when a tie-breaker is needed.

Consider this data:

https://fivethirtyeight.datasettes.com/fivethirtyeight-2628db9?sql=select+rowid%2C+*+from+%5Bnfl-wide-receivers%2Fadvanced-historical%5D%0D%0Aorder+by+case+when+career_ranypa+is+null+then+1+else+0+end%2C+career_ranypa%2C+rowid+limit+11

If the page size was set to 9 rather than 11, the page divide would be between those two rows with the same value in the career_ranypa column. What would the ?_next= token look like such that the correct row would be returned?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377362466 https://github.com/simonw/datasette/issues/189#issuecomment-377362466 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzM2MjQ2Ng== simonw 9599 2018-03-29T20:29:14Z 2018-03-29T20:29:14Z OWNER

Alternative idea: by default enable all sorting in the UI.

If a table has more than 100,000 rows disable sorting UI except for columns that have an index.

Allow this to be overridden in metadata.json

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377055663 https://github.com/simonw/datasette/issues/189#issuecomment-377055663 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzA1NTY2Mw== simonw 9599 2018-03-28T22:14:53Z 2018-03-28T22:14:53Z OWNER

There is one other interesting option for auto-enabling/disabling sort: the inspect command could include data about column index presence and whether or not a column has any null values in it.

This would allow us to dynamically include a "nulls last" option but only for columns that contain at least one null.

It's quite a lot of additional engineering for a very minor feature though, so I think I'll punt on that for the moment.

We may find that the _group_count feature can benefit from column value statistics later on though.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377054358 https://github.com/simonw/datasette/issues/189#issuecomment-377054358 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzA1NDM1OA== simonw 9599 2018-03-28T22:09:25Z 2018-03-28T22:09:25Z OWNER

I'm tempted to put these verbose sorting options inline in the page HTML but have them in the table footer so they don't clog up the top half of the page with uninteresting links - then use JavaScript to hoik them out into a dropdown menu attached to each column header.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377050461 https://github.com/simonw/datasette/issues/189#issuecomment-377050461 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzA1MDQ2MQ== simonw 9599 2018-03-28T21:55:14Z 2018-03-28T22:06:30Z OWNER

I think there are actually four kinds of sort order we need to support;

  • ascending
  • descending
  • ascending, nulls last
  • descending, nulls last

It looks like [-blah] is a valid SQLite table name, so mark I descending with a hyphen prefix isn't good.

Instead, maybe this:

?_sort_asc=col1&_sort_desc_nulls_last=col2
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377052634 https://github.com/simonw/datasette/issues/189#issuecomment-377052634 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzA1MjYzNA== simonw 9599 2018-03-28T22:03:16Z 2018-03-28T22:03:16Z OWNER

In terms of user interface: the obvious place to put this is as a drop down menu on the column headers.

This also means the UI can support combined sort orders. Assuming you are already sorted by county descending and you select the candidate column header, the options could be:

  • sort all by candidate
  • sort all by candidate, descending
  • sort by county descending, then by candidate
  • sort by county descending, then by candidate descending
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377051018 https://github.com/simonw/datasette/issues/189#issuecomment-377051018 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzA1MTAxOA== simonw 9599 2018-03-28T21:57:20Z 2018-03-28T22:00:17Z OWNER

I'd like to continue to support _next=token pagination even for custom sort orders.

To do that I should include rowid (or general primary key) as the tie breaker on all sorts so I can incorporate that it into the _next= token.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
377049625 https://github.com/simonw/datasette/issues/189#issuecomment-377049625 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3NzA0OTYyNQ== simonw 9599 2018-03-28T21:52:05Z 2018-03-28T21:52:05Z OWNER

This is a better pattern as you don't have to pick a minimum value:

ORDER BY CASE WHEN SOMECOL IS NULL THEN 1 ELSE 0 END, SOMECOL
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
376986668 https://github.com/simonw/datasette/issues/189#issuecomment-376986668 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3Njk4NjY2OA== simonw 9599 2018-03-28T18:21:53Z 2018-03-28T18:21:53Z OWNER

Might have to do something special to get sort-by-nulls-last: https://stackoverflow.com/questions/12503120/how-to-do-nulls-last-in-sqlite

order by ifnull(column_name, -999999)

Would need to figure out a smart way to get the default value - maybe by running a min() or max() against the column first?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
376983741 https://github.com/simonw/datasette/issues/189#issuecomment-376983741 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3Njk4Mzc0MQ== simonw 9599 2018-03-28T18:12:35Z 2018-03-28T18:12:35Z OWNER

I think this can work with a ?_sort=xxx parameter - and ?_sort=-xxx to sort in the opposite direction.

I'd like to support "sort by X descending, then by Y ascending if there are dupes for X" as well. Two ways that could work:

?_sort=-xxx,yyy

Or...

?_sort=-xxx&_sort=yyy

The second option is probably better in that it makes it easier for columns to have a comma in their name.

Is it possible for a SQLite column to start with a - character?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  
376981291 https://github.com/simonw/datasette/issues/189#issuecomment-376981291 https://api.github.com/repos/simonw/datasette/issues/189 MDEyOklzc3VlQ29tbWVudDM3Njk4MTI5MQ== simonw 9599 2018-03-28T18:06:08Z 2018-03-28T18:06:08Z OWNER

Given how unlikely it is that this will pose a real problem I think I like option 1: enable sort-by-column by default for all tables, then allow power users to instead switch to explicit enabling of the functionality in their metadata.json if they know their data is too big.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Ability to sort (and paginate) by column 309471814  

Advanced export

JSON shape: default, array, newline-delimited, object

CSV options:

CREATE TABLE [issue_comments] (
   [html_url] TEXT,
   [issue_url] TEXT,
   [id] INTEGER PRIMARY KEY,
   [node_id] TEXT,
   [user] INTEGER REFERENCES [users]([id]),
   [created_at] TEXT,
   [updated_at] TEXT,
   [author_association] TEXT,
   [body] TEXT,
   [reactions] TEXT,
   [issue] INTEGER REFERENCES [issues]([id])
, [performed_via_github_app] TEXT);
CREATE INDEX [idx_issue_comments_issue]
                ON [issue_comments] ([issue]);
CREATE INDEX [idx_issue_comments_user]
                ON [issue_comments] ([user]);
Powered by Datasette · Queries took 1.2ms · About: github-to-sqlite