{"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1339768422", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1339768422, "node_id": "IC_kwDOBm6k_c5P2z5m", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-12-06T18:04:59Z", "updated_at": "2022-12-06T18:04:59Z", "author_association": "OWNER", "body": "I realized this API should require both the `insert-row` AND the `update-row` permissions, since calls to it could do either one.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1339784569", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1339784569, "node_id": "IC_kwDOBm6k_c5P2315", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-12-06T18:16:15Z", "updated_at": "2022-12-06T18:17:56Z", "author_association": "OWNER", "body": "Just noticed the insert API returns `{}` when it should return `{\"ok\": true}` - will fix that here too.\r\n\r\nUPDATE: no it did that already, it was just the documentation that was wrong.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1339906241", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1339906241, "node_id": "IC_kwDOBm6k_c5P3VjB", "user": {"value": 22429695, "label": "codecov[bot]"}, "created_at": "2022-12-06T19:33:32Z", "updated_at": "2022-12-08T01:04:56Z", "author_association": "NONE", "body": "# [Codecov](https://codecov.io/gh/simonw/datasette/pull/1931?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) Report\nBase: **90.42**% // Head: **91.77**% // Increases project coverage by **`+1.34%`** :tada:\n> Coverage data is based on head [(`645be0f`)](https://codecov.io/gh/simonw/datasette/pull/1931?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) compared to base [(`cab5b60`)](https://codecov.io/gh/simonw/datasette/commit/cab5b60e09e94aca820dbec5308446a88c99ea3d?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison).\n> Patch coverage: 95.55% of modified lines in pull request are covered.\n\n> :exclamation: Current head 645be0f differs from pull request most recent head 7cd6fd9. Consider uploading reports for the commit 7cd6fd9 to get more accurate results\n\n
Additional details and impacted files\n\n\n```diff\n@@ Coverage Diff @@\n## main #1931 +/- ##\n==========================================\n+ Coverage 90.42% 91.77% +1.34% \n==========================================\n Files 36 36 \n Lines 5057 5019 -38 \n==========================================\n+ Hits 4573 4606 +33 \n+ Misses 484 413 -71 \n```\n\n\n| [Impacted Files](https://codecov.io/gh/simonw/datasette/pull/1931?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison) | Coverage \u0394 | |\n|---|---|---|\n| [datasette/views/special.py](https://codecov.io/gh/simonw/datasette/pull/1931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3ZpZXdzL3NwZWNpYWwucHk=) | `79.41% <0.00%> (\u00f8)` | |\n| [datasette/views/table.py](https://codecov.io/gh/simonw/datasette/pull/1931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3ZpZXdzL3RhYmxlLnB5) | `92.44% <97.43%> (+0.20%)` | :arrow_up: |\n| [datasette/app.py](https://codecov.io/gh/simonw/datasette/pull/1931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL2FwcC5weQ==) | `94.42% <100.00%> (+<0.01%)` | :arrow_up: |\n| [datasette/default\\_permissions.py](https://codecov.io/gh/simonw/datasette/pull/1931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL2RlZmF1bHRfcGVybWlzc2lvbnMucHk=) | `94.81% <100.00%> (+0.07%)` | :arrow_up: |\n| [datasette/views/database.py](https://codecov.io/gh/simonw/datasette/pull/1931/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison#diff-ZGF0YXNldHRlL3ZpZXdzL2RhdGFiYXNlLnB5) | `95.83% <0.00%> (+17.01%)` | :arrow_up: |\n\nHelp us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison)\n\n
\n\n[:umbrella: View full report at Codecov](https://codecov.io/gh/simonw/datasette/pull/1931?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Simon+Willison). \n:loudspeaker: Do you have feedback about the report comment? [Let us know in this issue](https://about.codecov.io/codecov-pr-comment-feedback/?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": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1339911152", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1339911152, "node_id": "IC_kwDOBm6k_c5P3Wvw", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-12-06T19:38:12Z", "updated_at": "2022-12-06T19:38:12Z", "author_association": "OWNER", "body": "Documentation: https://datasette--1931.org.readthedocs.build/en/1931/json_api.html#upserting-rows", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1339916064", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1339916064, "node_id": "IC_kwDOBm6k_c5P3X8g", "user": {"value": 3556, "label": "davidbgk"}, "created_at": "2022-12-06T19:42:45Z", "updated_at": "2022-12-06T19:42:45Z", "author_association": "CONTRIBUTOR", "body": "The `\"return\": true` option is really nice!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1339968514", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1339968514, "node_id": "IC_kwDOBm6k_c5P3kwC", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-12-06T20:28:47Z", "updated_at": "2022-12-06T20:28:47Z", "author_association": "OWNER", "body": "Should the `\"return\": true` mode reflect the order in which the rows were provided when the API was called?\r\n\r\nI think it should. Since this is small enough to happily fit in Python memory (thanks to the `max_insert_rows` setting) I can load the fresh data from the database and then sort it in Python space before returning it.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1341821213", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1341821213, "node_id": "IC_kwDOBm6k_c5P-pEd", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-12-08T00:58:21Z", "updated_at": "2022-12-08T00:58:21Z", "author_association": "OWNER", "body": "In the interests of shipping, I'm going to punt the API explorer to a later issue.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1931#issuecomment-1341825314", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1931", "id": 1341825314, "node_id": "IC_kwDOBm6k_c5P-qEi", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-12-08T01:03:18Z", "updated_at": "2022-12-08T01:03:18Z", "author_association": "OWNER", "body": "I broke this test:\r\n```\r\nds_write = \r\n\r\n @pytest.mark.asyncio\r\n async def test_insert_row(ds_write):\r\n token = write_token(ds_write)\r\n response = await ds_write.client.post(\r\n \"/data/docs/-/insert\",\r\n json={\"row\": {\"title\": \"Test\", \"score\": 1.2, \"age\": 5}},\r\n headers={\r\n \"Authorization\": \"***\".format(token),\r\n \"Content-Type\": \"application/json\",\r\n },\r\n )\r\n expected_row = {\"id\": 1, \"title\": \"Test\", \"score\": 1.2, \"age\": 5}\r\n> assert response.status_code == 201\r\nE assert 500 == 201\r\nE + where 500 = .status_code\r\n\r\n/home/runner/work/datasette/datasette/tests/test_api_write.py:43: AssertionError\r\n----------------------------- Captured stderr call -----------------------------\r\nTraceback (most recent call last):\r\n File \"/home/runner/work/datasette/datasette/datasette/app.py\", line 1447, in route_path\r\n response = await view(request, send)\r\n File \"/home/runner/work/datasette/datasette/datasette/views/base.py\", line 151, in view\r\n return await self.dispatch_request(request)\r\n File \"/home/runner/work/datasette/datasette/datasette/views/base.py\", line 105, in dispatch_request\r\n response = await handler(request)\r\n File \"/home/runner/work/datasette/datasette/datasette/views/table.py\", line 1228, in post\r\n row_pk_values_for_later = [tuple(row[pk] for pk in pks) for row in rows]\r\n File \"/home/runner/work/datasette/datasette/datasette/views/table.py\", line 1228, in \r\n row_pk_values_for_later = [tuple(row[pk] for pk in pks) for row in rows]\r\n File \"/home/runner/work/datasette/datasette/datasette/views/table.py\", line 1228, in \r\n row_pk_values_for_later = [tuple(row[pk] for pk in pks) for row in rows]\r\nKeyError: 'id'\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1473814539, "label": "/db/table/-/upsert"}, "performed_via_github_app": null}