{"id": 1421529723, "node_id": "I_kwDOBm6k_c5UutJ7", "number": 1850, "title": "Write API in Datasette core", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 13, "created_at": "2022-10-24T22:13:24Z", "updated_at": "2022-11-29T20:11:20Z", "closed_at": "2022-11-29T20:11:20Z", "author_association": "OWNER", "pull_request": null, "body": "I need this for Datasette Cloud, and in thinking it through I realized that it's really time Datasette grew a default write API as well.\r\n\r\nI'm going to mostly model this off `sqlite-utils`, since I've spent a bunch of time iterating on a pseudo-JSON API for that over the past few years (piping JSON to stdin etc).\r\n\r\nI want this for Datasette 1.0. I'm going to be building it in the new [1.0-dev](https://github.com/simonw/datasette/tree/1.0-dev) branch, which is automatically deployed to https://latest-1-0-dev.datasette.io/ running on Cloud Run.\r\n\r\nAPI features to build:\r\n\r\n- [x] #1852\r\n - [x] #1856\r\n - [x] #1857\r\n - [x] #1858\r\n - [x] #1859\r\n- [x] #1871\r\n - [x] #1888\r\n- [x] #1868\r\n- [x] #1851\r\n- [x] #1863\r\n- [x] #1864\r\n- [x] #1866\r\n- [x] https://github.com/simonw/datasette/issues/1882\r\n- [x] #1862\r\n- [x] #1874\r\n - [x] https://github.com/simonw/datasette/issues/1887\r\n- [x] #1877\r\n\r\nBumped to later on:\r\n\r\n- #1855\r\n- #1878\r\n- #1873\r\n- #1875\r\n- Make sure CORS works\r\n- https://github.com/simonw/datasette/issues/1889\r\n- Alter a table - `sqlite-utils transform` style (more powerful than straight ALTER)\r\n- Execute SQL against a write connection\r\n- Maybe even multiple write SQL statements bundled in a single transaction\r\n- https://github.com/simonw/datasette/issues/1867\r\n", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1850/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1468603401, "node_id": "I_kwDOBm6k_c5XiRwJ", "number": 1913, "title": "Release Datasette 1.0a0", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 9, "created_at": "2022-11-29T19:41:42Z", "updated_at": "2022-11-29T20:10:35Z", "closed_at": "2022-11-29T20:10:35Z", "author_association": "OWNER", "pull_request": null, "body": "I attempted the release just now - https://github.com/simonw/datasette/releases/tag/1.0a0 - and got an unexpected test failure:\r\n\r\nhttps://github.com/simonw/datasette/actions/runs/3577355358/attempts/1\r\n\r\n```\r\n> assert delete_response.status_code == 200\r\nE assert 404 == 200\r\nE + where 404 = .status_code\r\n\r\n/home/runner/work/datasette/datasette/tests/test_api_write.py:396: AssertionError\r\n=========================== short test summary info ============================\r\nFAILED tests/test_api_write.py::test_delete_row[compound_pk_table-row_for_create2-pks2-article,k] - assert 404 == 200\r\n + where 404 = .status_code\r\n```\r\nI hit \"retry\" on that test but I expect it to fail again.\r\n\r\n", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1913/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1432012302, "node_id": "I_kwDOBm6k_c5VWsYO", "number": 1877, "title": "Refactor and tidy up final write API code", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": null, "comments": 1, "created_at": "2022-11-01T20:00:11Z", "updated_at": "2022-11-29T19:44:16Z", "closed_at": "2022-11-29T19:44:07Z", "author_association": "OWNER", "pull_request": null, "body": "- `views/table.py` has got a bit too big - I think the write classes should be pulled out into a separate module.\r\n- [x] There's duplicate logic for deciding if the table and database exist and checking permissions", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1877/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1450312343, "node_id": "I_kwDOBm6k_c5WcgKX", "number": 1892, "title": "Merge 1.0-dev branch back to main", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 3, "created_at": "2022-11-15T20:04:25Z", "updated_at": "2022-11-29T19:40:23Z", "closed_at": "2022-11-29T19:40:23Z", "author_association": "OWNER", "pull_request": null, "body": "I'm committed enough to the 1.0 work now that I'm ready for the `main` branch to reflect that instead.\r\n\r\nIf I need to make any dot-releases against 0.63 I can do those from a branch.", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1892/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1468592292, "node_id": "PR_kwDOBm6k_c5D6nzE", "number": 1912, "title": "Merge 1.0-dev (with initial write API) back into main", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": null, "comments": 1, "created_at": "2022-11-29T19:31:21Z", "updated_at": "2022-11-29T19:39:37Z", "closed_at": "2022-11-29T19:39:36Z", "author_association": "OWNER", "pull_request": "simonw/datasette/pulls/1912", "body": "See:\r\n- #1892\r\n\r\n\r\n----\n:books: Documentation preview :books:: https://datasette--1912.org.readthedocs.build/en/1912/\n\r\n", "repo": {"value": 107914493, "label": "datasette"}, "type": "pull", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1912/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": 0, "state_reason": null} {"id": 1450303205, "node_id": "I_kwDOBm6k_c5Wcd7l", "number": 1891, "title": "1.0a0 release notes", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 4, "created_at": "2022-11-15T19:58:20Z", "updated_at": "2022-11-29T19:23:41Z", "closed_at": "2022-11-29T19:23:41Z", "author_association": "OWNER", "pull_request": null, "body": "This release will mainly help preview the new Datasette write API:\r\n- #1850", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1891/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1425029275, "node_id": "I_kwDOBm6k_c5U8Dib", "number": 1864, "title": "Delete a single record from an existing table", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 4, "created_at": "2022-10-27T04:53:22Z", "updated_at": "2022-11-29T18:54:04Z", "closed_at": "2022-11-29T18:54:04Z", "author_association": "OWNER", "pull_request": null, "body": "API design:\r\n```\r\nPOST /db/table/row-pks/-/delete\r\nOr...\r\nDELETE /db/table/row-pks/-/delete\r\n```\r\nI'm just going to do `POST` for the moment, like I did here:\r\n- #1874\r\n\r\nPermission: `delete-row`\r\n\r\nStill needed:\r\n\r\n- [ ] Tests for rowid tables\r\n- [ ] Tests for compound primary keys", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1864/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1468519699, "node_id": "I_kwDOBm6k_c5Xh9UT", "number": 1911, "title": "`/db/-/create` should support creating tables with compound primary keys", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 2, "created_at": "2022-11-29T18:30:47Z", "updated_at": "2022-11-29T18:50:58Z", "closed_at": "2022-11-29T18:48:05Z", "author_association": "OWNER", "pull_request": null, "body": "Found myself needing this to write the tests for:\r\n- #1864 ", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1911/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"} {"id": 1425029242, "node_id": "I_kwDOBm6k_c5U8Dh6", "number": 1863, "title": "Update a single record in an existing table", "user": {"value": 9599, "label": "simonw"}, "state": "closed", "locked": 0, "assignee": null, "milestone": {"value": 8658075, "label": "Datasette 1.0a0"}, "comments": 16, "created_at": "2022-10-27T04:53:17Z", "updated_at": "2022-11-29T18:08:53Z", "closed_at": "2022-11-29T18:06:37Z", "author_association": "OWNER", "pull_request": null, "body": "API design:\r\n\r\n```\r\nPOST /db/table/row-pks/-/update\r\n{\r\n \"field\": \"updated_value\"\r\n}\r\n```\r\nOnly the fields that you pass will be updated.\r\n\r\nMaybe this is the wrong design though? The design for insert currently looks like this:\r\n\r\n- https://github.com/simonw/datasette/issues/1851#issuecomment-1294224185\r\n\r\n```\r\nPOST /db/table/-/insert\r\nAuthorization: Bearer xxx\r\nContent-Type: application/json\r\n{\r\n \"row\": {\r\n \"id\": 1,\r\n \"name\": \"New name\"\r\n }\r\n}\r\n```\r\nI could use the same format for `/-/update`, but in this case the API doesn't require you to pass every field so `\"row\"` doesn't seem like the right key.\r\n\r\nI think I'll go with this:\r\n\r\n```\r\nPOST /db/table/1/-/update\r\nAuthorization: Bearer xxx\r\nContent-Type: application/json\r\n{\r\n \"update\": {\r\n \"name\": \"New name\"\r\n }\r\n}\r\n```\r\nThe benefit of having an `\"update\"` key is that it allows me to use other keys in the future. Maybe a `\"alter\": true` key to indicate that new columns should be added if they are missing.", "repo": {"value": 107914493, "label": "datasette"}, "type": "issue", "active_lock_reason": null, "performed_via_github_app": null, "reactions": "{\"url\": \"https://api.github.com/repos/simonw/datasette/issues/1863/reactions\", \"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "draft": null, "state_reason": "completed"}