home / github

Menu
  • Search all tables
  • GraphQL API

issue_comments

Table actions
  • GraphQL API for issue_comments

4 rows where author_association = "OWNER", issue = 1318907685 and user = 9599 sorted by updated_at descending

✖
✖
✖
✖

✎ View and edit SQL

This data as json, CSV (advanced)

Suggested facets: updated_at (date)

user 1

  • simonw · 4 ✖

issue 1

  • 500 error if sorted by a column not in the ?_col= list · 4 ✖

author_association 1

  • OWNER · 4 ✖
id html_url issue_url node_id user created_at updated_at ▲ author_association body reactions issue performed_via_github_app
1214407104 https://github.com/simonw/datasette/issues/1773#issuecomment-1214407104 https://api.github.com/repos/simonw/datasette/issues/1773 IC_kwDOBm6k_c5IYmHA simonw 9599 2022-08-14T16:06:25Z 2022-08-14T16:06:25Z OWNER

https://latest.datasette.io/fixtures/sortable?_sort_desc=sortable&_col=sortable_with_nulls works now.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error if sorted by a column not in the ?_col= list 1318907685  
1196167102 https://github.com/simonw/datasette/issues/1773#issuecomment-1196167102 https://api.github.com/repos/simonw/datasette/issues/1773 IC_kwDOBm6k_c5HTA-- simonw 9599 2022-07-27T01:28:02Z 2022-07-27T01:28:02Z OWNER

So code would look something like this:

python 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()

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error if sorted by a column not in the ?_col= list 1318907685  
1196166269 https://github.com/simonw/datasette/issues/1773#issuecomment-1196166269 https://api.github.com/repos/simonw/datasette/issues/1773 IC_kwDOBm6k_c5HTAx9 simonw 9599 2022-07-27T01:26:09Z 2022-07-27T01:26:09Z OWNER

So the problem here is that in generating the ?_next= next page link we need the value from the specified sort column - but we're not selecting it any more.

Possible fixes:

  • Always include the sort column in the list of columns that are selected, then filter that out before they are displayed
  • Use a second query to figure out the _sort or _sort_desc value for that last row, since we know its primary key (we always select primary keys)

Not sure which solution is more elegant. I think it might be the second one.

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error if sorted by a column not in the ?_col= list 1318907685  
1196165351 https://github.com/simonw/datasette/issues/1773#issuecomment-1196165351 https://api.github.com/repos/simonw/datasette/issues/1773 IC_kwDOBm6k_c5HTAjn simonw 9599 2022-07-27T01:24:13Z 2022-07-27T01:24:13Z OWNER

Traceback: Traceback (most recent call last): File "/Users/simon/Dropbox/Development/datasette/datasette/app.py", line 1264, in route_path response = await view(request, send) File "/Users/simon/Dropbox/Development/datasette/datasette/views/base.py", line 134, in view return await self.dispatch_request(request) File "/Users/simon/Dropbox/Development/datasette/datasette/views/base.py", line 91, in dispatch_request return await handler(request) File "/Users/simon/Dropbox/Development/datasette/datasette/views/base.py", line 361, in get response_or_template_contexts = await self.data(request, **data_kwargs) File "/Users/simon/Dropbox/Development/datasette/datasette/views/table.py", line 157, in data return await self._data_traced(request, default_labels, _next, _size) File "/Users/simon/Dropbox/Development/datasette/datasette/views/table.py", line 633, in _data_traced prefix = rows[-2][sort or sort_desc] IndexError: No item with that key That's this code here: https://github.com/simonw/datasette/blob/7af67b54b7d9bca43e948510fc62f6db2b748fa8/datasette/views/table.py#L631-L645

{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
500 error if sorted by a column not in the ?_col= list 1318907685  

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 1097.675ms · About: github-to-sqlite
  • Sort ascending
  • Sort descending
  • Facet by this
  • Hide this column
  • Show all columns
  • Show not-blank rows