github
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/1851#issuecomment-1289712350 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1289712350 | IC_kwDOBm6k_c5M33Le | 9599 | 2022-10-24T22:28:39Z | 2022-10-27T23:18:48Z | OWNER | API design: (**UPDATE: this was [later changed to POST /db/table/-/insert](https://github.com/simonw/datasette/issues/1851#issuecomment-1294224185)) ``` POST /db/table Authorization: Bearer xxx Content-Type: application/json { "row": { "id": 1, "name": "New record" } } ``` Returns: ``` 201 Created { "row": { "id": 1, "name": "New record" } } ``` You can omit optional fields in the input, including the ID field. The returned object will always include all fields - and will even include `rowid` if your object doesn't have a primary key of its own. I decided to use `"row"` as the key in both request and response, to preserve space for other future keys - one that tells you that the table has been created, for example. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1294012583 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1294012583 | IC_kwDOBm6k_c5NIRCn | 9599 | 2022-10-27T20:11:22Z | 2022-10-27T20:11:22Z | OWNER | And the response to `"inserted": [{...}]` - it will be the same for bulk inserts. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1294012084 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1294012084 | IC_kwDOBm6k_c5NIQ60 | 9599 | 2022-10-27T20:10:47Z | 2022-10-27T20:10:47Z | OWNER | I'm going to change the incoming JSON back to `{"row": {...}}` - no need to POST `{"insert": ...}` to something with `/-/insert` in the URL already. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1294009354 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1294009354 | IC_kwDOBm6k_c5NIQQK | 9599 | 2022-10-27T20:07:42Z | 2022-10-27T20:07:42Z | OWNER | Need to implement the new URL design from: - #1868 This is now going to be `/db/table/-/insert` - and it will eventually handle bulk inserts as well as single inserts. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1293996735 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1293996735 | IC_kwDOBm6k_c5NINK_ | 9599 | 2022-10-27T19:54:53Z | 2022-10-27T19:54:53Z | OWNER | Updated docs: https://docs.datasette.io/en/1.0-dev/json_api.html#inserting-a-single-row <img width="867" alt="image" src="https://user-images.githubusercontent.com/9599/198385667-e4cf9930-0621-49d7-9fed-347aa96b7581.png"> | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1292997608 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1292997608 | IC_kwDOBm6k_c5NEZPo | 9599 | 2022-10-27T04:54:53Z | 2022-10-27T19:05:50Z | OWNER | I'm going to change the design of this to: ``` { "insert": { "title" :"..." } } ``` Renaming `"row"` to `"insert"`. This will be consistent with adding `"drop": true` for dropping a table, and maybe other verbs like for modifying the schema. The API response will look like this: ```json { "inserted_row": { "id": 1, "title": "..." } } ``` | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1292999579 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1292999579 | IC_kwDOBm6k_c5NEZub | 9599 | 2022-10-27T04:59:06Z | 2022-10-27T04:59:12Z | OWNER | I should probably refactor this to use `sqlite-utils`, since I'm going to want to use that later for the feature that automatically creates tables. Might make it easier to solve the rowid issues too. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1292996181 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1292996181 | IC_kwDOBm6k_c5NEY5V | 9599 | 2022-10-27T04:51:47Z | 2022-10-27T04:51:47Z | OWNER | Also need a test for invalid JSON (currently triggers a 500 HTML error). | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1292952121 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1292952121 | IC_kwDOBm6k_c5NEOI5 | 9599 | 2022-10-27T04:24:09Z | 2022-10-27T04:24:20Z | OWNER | And come up with a whole bunch of tests for weird table shapes, surprising column names, different types etc. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1292951833 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1292951833 | IC_kwDOBm6k_c5NEOEZ | 9599 | 2022-10-27T04:23:40Z | 2022-10-27T04:23:40Z | OWNER | Also need to think about transactions - it should use them! | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 | |
https://github.com/simonw/datasette/issues/1851#issuecomment-1292939146 | https://api.github.com/repos/simonw/datasette/issues/1851 | 1292939146 | IC_kwDOBm6k_c5NEK-K | 9599 | 2022-10-27T04:00:17Z | 2022-10-27T04:23:15Z | OWNER | Documentation for this first draft of the API: https://docs.datasette.io/en/1.0-dev/json_api.html#inserting-a-single-row It currently returns errors as HTML - it needs to return errors as JSON. Also the errors need comprehensive test coverage. I'm also worried about what happens if you use it on a table that doesn't use an integer primary key - need to check that. I think this code may break: https://github.com/simonw/datasette/blob/51c436fed29205721dcf17fa31d7e7090d34ebb8/datasette/views/table.py#L155-L171 Plus will `rowid` tables without an explicit primary key return the `rowid` column? They should. | { "total_count": 0, "+1": 0, "-1": 0, "laugh": 0, "hooray": 0, "confused": 0, "heart": 0, "rocket": 0, "eyes": 0 } |
1421544654 |