home / github / issue_comments

Menu
  • Search all tables
  • GraphQL API

issue_comments: 1029695083

This data as json

html_url issue_url id node_id user created_at updated_at author_association body reactions issue performed_via_github_app
https://github.com/simonw/datasette/issues/1080#issuecomment-1029695083 https://api.github.com/repos/simonw/datasette/issues/1080 1029695083 IC_kwDOBm6k_c49X-Zr 9599 2022-02-04T06:24:40Z 2022-02-04T06:25:18Z OWNER

An initial prototype of that in my local group-count branch quickly started running into problems: ```diff diff --git a/datasette/views/table.py b/datasette/views/table.py index be9e9c3..d30efe1 100644 --- a/datasette/views/table.py +++ b/datasette/views/table.py @@ -105,8 +105,12 @@ class RowTableShared(DataView): type_ = "integer" notnull = 0 else: - type_ = column_details[r[0]].type - notnull = column_details[r[0]].notnull + try: + type_ = column_details[r[0]].type + notnull = column_details[r[0]].notnull + except KeyError: # Probably count(*) + type_ = "integer" + notnull = False columns.append( { "name": r[0], @@ -613,6 +617,15 @@ class TableView(RowTableShared): offset=offset, )

  • If ?_group_count we convert the SQL query here

  • group_count = request.args.getlist("_group_count")
  • if group_count:
  • wrapped_sql = "select {cols}, count(*) from ({sql}) group by {cols}".format(
  • cols=", ".join(group_count),
  • sql=sql,
  • )
  • sql = wrapped_sql + if request.args.get("_timelimit"): extra_args["custom_time_limit"] = int(request.args.get("_timelimit")) Resulted in errors like this one: pk_path = path_from_row_pks(row, pks, not pks, False) File "/Users/simon/Dropbox/Development/datasette/datasette/utils/init.py", line 82, in path_from_row_pks bits = [ File "/Users/simon/Dropbox/Development/datasette/datasette/utils/init.py", line 83, in <listcomp> row[pk]["value"] if isinstance(row[pk], dict) else row[pk] for pk in pks IndexError: No item with that key ```
{
    "total_count": 0,
    "+1": 0,
    "-1": 0,
    "laugh": 0,
    "hooray": 0,
    "confused": 0,
    "heart": 0,
    "rocket": 0,
    "eyes": 0
}
734777631  
Powered by Datasette · Queries took 2.395ms · About: github-to-sqlite