{"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-1179758180", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 1179758180, "node_id": "IC_kwDOBm6k_c5GUa5k", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-10T16:23:34Z", "updated_at": "2022-07-10T16:23:57Z", "author_association": "OWNER", "body": "But do I need to pass the `use_rowid` boolean here as well, as used by `def path_from_row_pks(row, pks, use_rowid, quote=True)`? Or can I derive that from the fact that `pks` is an empty tuple?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-719996693", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 719996693, "node_id": "MDEyOklzc3VlQ29tbWVudDcxOTk5NjY5Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-10-31T22:32:09Z", "updated_at": "2022-07-10T16:22:48Z", "author_association": "OWNER", "body": "The `row_path` part of these really isn't very user friendly, since you need to properly URL-encode the values. The safest way to do so is by calling this obscure, undocumented utility function: https://github.com/simonw/datasette/blob/f0bd2d05f5f7832df4879822afb99d2096c00d48/datasette/utils/__init__.py#L84-L98\r\n\r\nThis feels like it should be improved before I turn it into a documented API.\r\n\r\n(Note that this API deals with a `row` that is a potentially-nested dictionary - not with a `sqlite3.Row` object.)", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-1179757912", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 1179757912, "node_id": "IC_kwDOBm6k_c5GUa1Y", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-10T16:21:38Z", "updated_at": "2022-07-10T16:21:38Z", "author_association": "OWNER", "body": "I think the best way to do this is to change the method signatures to:\r\n```python\r\n def row(self, database, table, row, pks): \r\n ...\r\n \r\n def row_blob(self, database, table, row, pks, column): \r\n ... \r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-1179757605", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 1179757605, "node_id": "IC_kwDOBm6k_c5GUawl", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-10T16:19:42Z", "updated_at": "2022-07-10T16:21:03Z", "author_association": "OWNER", "body": "If I do require `pks` to be passed here, maybe I could make those available to the `render_cell()` plugin hook to at least make this a bit more pleasant for plugin authors to use?\r\n\r\nCurrent hook: https://docs.datasette.io/en/latest/plugin_hooks.html#render-cell-row-value-column-table-database-datasette\r\n\r\nhttps://github.com/simonw/datasette/blob/035dc5e7b95142d4a700819a8cc4ff64aefe4efe/datasette/hookspecs.py#L62-L64\r\n\r\nThe hook is called in two places in the codebase - when rendering a table (`pks` variable is already in scope here):\r\n\r\nhttps://github.com/simonw/datasette/blob/6373bb341457e5becfd5b67792ac2c8b9ed7c384/datasette/views/table.py#L897-L904\r\n\r\nAnd when rendering an arbitrary query:\r\n\r\nhttps://github.com/simonw/datasette/blob/6373bb341457e5becfd5b67792ac2c8b9ed7c384/datasette/views/database.py#L377-L384\r\n\r\nNote that in that second one `table` is `None` (which is also called out in the documentation) - `pks` would be `None` here too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-1179757067", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 1179757067, "node_id": "IC_kwDOBm6k_c5GUaoL", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-10T16:16:19Z", "updated_at": "2022-07-10T16:16:19Z", "author_association": "OWNER", "body": "None of the potential solutions for that problem are particularly appealing:\r\n\r\n- Make these URL generation methods `async` - should the other ones be `async` too for consistency?\r\n- Have some kind of mechanism that calculates and caches the `pks` for each table somewhere which can then be accessed here without an `async` call\r\n- Require `pks` is passed to these methods, having been looked up elsewhere. This is a bit gross but may end up being the best solution", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-1179756689", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 1179756689, "node_id": "IC_kwDOBm6k_c5GUaiR", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-10T16:14:03Z", "updated_at": "2022-07-10T16:14:03Z", "author_association": "OWNER", "body": "I'm considering changing these functions to accept the `row` object itself:\r\n\r\n```python\r\n def row(self, database, table, row): \r\n ...\r\n \r\n def row_blob(self, database, table, row, column): \r\n ... \r\n```\r\nJust one catch: in order to generate the correct `row_path` we need to know the primary keys for that table. We can look those up based on having access to `database` and `table`, but doing so requires an `await ...` operation - and these functions are not `async`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1048#issuecomment-1179756391", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1048", "id": 1179756391, "node_id": "IC_kwDOBm6k_c5GUadn", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-07-10T16:12:23Z", "updated_at": "2022-07-10T16:12:23Z", "author_association": "OWNER", "body": "Also related: `row` is now available to `render_cell()` hook as-of this issue:\r\n- https://github.com/simonw/datasette/issues/1300", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 728905098, "label": "Documentation and unit tests for urls.row() urls.row_blob() methods"}, "performed_via_github_app": null}