home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

8 rows where issue = 314665147, "updated_at" is on date 2018-04-16 and user = 9599 sorted by updated_at descending

✎ View and edit SQL

This data as json, CSV (advanced)

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

user 1

  • simonw · 8 ✖

issue 1

  • Bug: Sort by column with NULL in next_page URL · 8 ✖

author_association 1

  • OWNER 8
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
381786522 https://github.com/simonw/datasette/issues/216#issuecomment-381786522 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTc4NjUyMg== simonw 9599 2018-04-16T23:58:45Z 2018-04-16T23:59:13Z OWNER

Weird... tests are failing in Travis, despite passing on my local machine. https://travis-ci.org/simonw/datasette/builds/367423706

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381649437 https://github.com/simonw/datasette/issues/216#issuecomment-381649437 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0OTQzNw== simonw 9599 2018-04-16T15:39:21Z 2018-04-16T15:39:21Z OWNER

Here's where that SQL gets constructed at the moment:

https://github.com/simonw/datasette/blob/10a34f995c70daa37a8a2aa02c3135a4b023a24c/datasette/app.py#L761-L771

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381649140 https://github.com/simonw/datasette/issues/216#issuecomment-381649140 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0OTE0MA== simonw 9599 2018-04-16T15:38:29Z 2018-04-16T15:38:29Z OWNER

But what would that SQL look like for _sort_desc?

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381648053 https://github.com/simonw/datasette/issues/216#issuecomment-381648053 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0ODA1Mw== simonw 9599 2018-04-16T15:35:17Z 2018-04-16T15:35:17Z OWNER

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

select rowid, * from [2017 Maryland state salaries] where (middle_initial is not null or (middle_initial is null and rowid > :p0)) order by middle_initial limit 101

Though this will also need to be taken into account for #198

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381645973 https://github.com/simonw/datasette/issues/216#issuecomment-381645973 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0NTk3Mw== simonw 9599 2018-04-16T15:29:11Z 2018-04-16T15:29:11Z OWNER

I could use $null as a magic value that means None. Since I'm applying quote_plus() to actual values, any legit strings that look like this will be encoded as %24null:

```

urllib.parse.quote_plus('$null') '%24null' ```

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381645274 https://github.com/simonw/datasette/issues/216#issuecomment-381645274 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0NTI3NA== simonw 9599 2018-04-16T15:27:16Z 2018-04-16T15:27:16Z OWNER

Relevant code:

https://github.com/simonw/datasette/blob/904f1c75a3c17671d25c53b91e177c249d14ab3b/datasette/app.py#L828-L832

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381644355 https://github.com/simonw/datasette/issues/216#issuecomment-381644355 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0NDM1NQ== simonw 9599 2018-04-16T15:24:38Z 2018-04-16T15:24:38Z OWNER

So there are two tricky problems to solve here:

  • I need a way of encoding null into that _next= that is unambiguous from the string None or null. This means introducing some kind of escaping mechanism in those strings. I already use URL encoding as part of the construction of those components here, maybe that can help here?
  • I need to figure out what the SQL should be for the "next" set of results if the previous value was null. Thankfully we use the primary key as a tie-breaker so this shouldn't be impossible.
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  
381643173 https://github.com/simonw/datasette/issues/216#issuecomment-381643173 https://api.github.com/repos/simonw/datasette/issues/216 MDEyOklzc3VlQ29tbWVudDM4MTY0MzE3Mw== simonw 9599 2018-04-16T15:21:17Z 2018-04-16T15:21:17Z OWNER

Yikes, definitely a bug.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
Bug: Sort by column with NULL in next_page URL 314665147  

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 397.748ms · About: github-to-sqlite