{"html_url": "https://github.com/simonw/datasette/issues/1773#issuecomment-1196165351", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1773", "id": 1196165351, "node_id": "IC_kwDOBm6k_c5HTAjn", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-27T01:24:13Z", "updated_at": "2022-07-27T01:24:13Z", "author_association": "OWNER", "body": "Traceback:\r\n```\r\nTraceback (most recent call last):\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/app.py\", line 1264, in route_path\r\n response = await view(request, send)\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/views/base.py\", line 134, in view\r\n return await self.dispatch_request(request)\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/views/base.py\", line 91, in dispatch_request\r\n return await handler(request)\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/views/base.py\", line 361, in get\r\n response_or_template_contexts = await self.data(request, **data_kwargs)\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/views/table.py\", line 157, in data\r\n return await self._data_traced(request, default_labels, _next, _size)\r\n File \"/Users/simon/Dropbox/Development/datasette/datasette/views/table.py\", line 633, in _data_traced\r\n prefix = rows[-2][sort or sort_desc]\r\nIndexError: No item with that key\r\n```\r\nThat's this code here: https://github.com/simonw/datasette/blob/7af67b54b7d9bca43e948510fc62f6db2b748fa8/datasette/views/table.py#L631-L645", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1318907685, "label": "500 error if sorted by a column not in the ?_col= list"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1773#issuecomment-1196166269", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1773", "id": 1196166269, "node_id": "IC_kwDOBm6k_c5HTAx9", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-27T01:26:09Z", "updated_at": "2022-07-27T01:26:09Z", "author_association": "OWNER", "body": "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.\r\n\r\nPossible fixes:\r\n\r\n- Always include the sort column in the list of columns that are selected, then filter that out before they are displayed\r\n- 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)\r\n\r\nNot sure which solution is more elegant. I think it might be the second one.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1318907685, "label": "500 error if sorted by a column not in the ?_col= list"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1773#issuecomment-1196167102", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1773", "id": 1196167102, "node_id": "IC_kwDOBm6k_c5HTA--", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-27T01:28:02Z", "updated_at": "2022-07-27T01:28:02Z", "author_association": "OWNER", "body": "So code would look something like this:\r\n\r\n```python\r\ntry:\r\n prefix = rows[-2][sort or sort_desc]\r\nexcept KeyError:\r\n # Didn't select sort/sort_desc column - look up value by primary key instead\r\n primary_key = rows[-2][\"pk\"] # But more complex than this\r\n prefix = (await db.execute(\"select * from {table} where pk = ?\", [primary_key])).first_value()\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1318907685, "label": "500 error if sorted by a column not in the ?_col= list"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/457#issuecomment-1197108865", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/457", "id": 1197108865, "node_id": "IC_kwDOCGYnMM5HWm6B", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-27T17:58:10Z", "updated_at": "2022-07-27T17:58:10Z", "author_association": "OWNER", "body": "Here's the build from the PR: https://sqlite-utils--457.org.readthedocs.build/en/457/", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1319881016, "label": "Link to installation instructions"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/pull/457#issuecomment-1197090890", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/457", "id": 1197090890, "node_id": "IC_kwDOCGYnMM5HWihK", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2022-07-27T17:40:14Z", "updated_at": "2022-07-27T17:40:40Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/sqlite-utils/pull/457?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\n> Merging [#457](https://codecov.io/gh/simonw/sqlite-utils/pull/457?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (80b3907) into [main](https://codecov.io/gh/simonw/sqlite-utils/commit/9e6cceac1c0e086429e2d308b700e59cc53a1991?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) (9e6ccea) will **not change** coverage.\n> The diff coverage is `n/a`.\n\n```diff\n@@ Coverage Diff @@\n## main #457 +/- ##\n=======================================\n Coverage 96.64% 96.64% \n=======================================\n Files 6 6 \n Lines 2566 2566 \n=======================================\n Hits 2480 2480 \n Misses 86 86 \n```\n\n\n\n------\n\n[Continue to review full report at Codecov](https://codecov.io/gh/simonw/sqlite-utils/pull/457?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n> `\u0394 = absolute (impact)`, `\u00f8 = not affected`, `? = missing data`\n> Powered by [Codecov](https://codecov.io/gh/simonw/sqlite-utils/pull/457?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Last update [9e6ccea...80b3907](https://codecov.io/gh/simonw/sqlite-utils/pull/457?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1319881016, "label": "Link to installation instructions"}, "performed_via_github_app": null}