{"html_url": "https://github.com/simonw/datasette/issues/1470#issuecomment-938124652", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1470", "id": 938124652, "node_id": "IC_kwDOBm6k_c436qVs", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-10-07T20:17:53Z", "updated_at": "2021-10-07T20:18:55Z", "author_association": "OWNER", "body": "Here's the exception:\r\n```\r\n-> params[f\"p{len(params)}\"] = components[0]\r\n(Pdb) list\r\n603 \t\r\n604 \t # Figure out the SQL for next-based-on-primary-key first\r\n605 \t next_by_pk_clauses = []\r\n606 \t if use_rowid:\r\n607 \t next_by_pk_clauses.append(f\"rowid > :p{len(params)}\")\r\n608 ->\t params[f\"p{len(params)}\"] = components[0]\r\n609 \t else:\r\n610 \t # Apply the tie-breaker based on primary keys\r\n611 \t if len(components) == len(pks):\r\n612 \t param_len = len(params)\r\n613 \t next_by_pk_clauses.append(\r\n```\r\nDebugger shows that `components` is an empty array, so `components[0]` cannot be resolved:\r\n\r\n```\r\n-> params[f\"p{len(params)}\"] = components[0]\r\n(Pdb) params\r\n{'search': 'hello'}\r\n(Pdb) components\r\n[]\r\n```\r\n\r\nSo the bug is in this code: https://github.com/simonw/datasette/blob/adb5b70de5cec3c3dd37184defe606a082c232cf/datasette/views/table.py#L604-L617\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 995098231, "label": "?_sort=rowid with _next= returns error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1470#issuecomment-938131806", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1470", "id": 938131806, "node_id": "IC_kwDOBm6k_c436sFe", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-10-07T20:28:30Z", "updated_at": "2021-10-07T20:28:30Z", "author_association": "OWNER", "body": "On further investigation this isn't related to `_search` at all - it happens when you explicitly sort by `_sort=rowid` and apply a `_next`\r\n\r\n- https://global-power-plants.datasettes.com/global-power-plants/global-power-plants?_next=200 works without an error (currently)\r\n- https://global-power-plants.datasettes.com/global-power-plants/global-power-plants?_next=200&_sort=rowid shows that error", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 995098231, "label": "?_sort=rowid with _next= returns error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1470#issuecomment-939386591", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1470", "id": 939386591, "node_id": "IC_kwDOBm6k_c43_ebf", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-10-10T01:17:34Z", "updated_at": "2021-10-10T01:17:34Z", "author_association": "OWNER", "body": "I'll open a separate issue for removing `_next=` when running a search.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 995098231, "label": "?_sort=rowid with _next= returns error"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1470#issuecomment-946097058", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1470", "id": 946097058, "node_id": "IC_kwDOBm6k_c44ZEui", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-10-18T19:30:15Z", "updated_at": "2021-10-18T19:30:15Z", "author_association": "OWNER", "body": "https://global-power-plants.datasettes.com/global-power-plants/global-power-plants?_next=200&_sort=rowid is fixed now.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 995098231, "label": "?_sort=rowid with _next= returns error"}, "performed_via_github_app": null}