{"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1385807684", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1385807684, "node_id": "IC_kwDOBm6k_c5Smb9E", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-17T17:51:54Z", "updated_at": "2023-01-19T23:20:59Z", "author_association": "OWNER", "body": "In most cases, the `?_extra=xxx` name exactly corresponds to the additional key that is added to the JSON.\r\n\r\n`?_facet=...` is one example of a query string argument that causes an extra key - `\"facet_results\"` - to be added to the JSON even though it wasn't requested by name in a `?_extra=`.\r\n\r\nAm I OK with that? I think so.\r\n\r\nRelated issue:\r\n- #1558 \r\n\r\nActually there's an edge-case here that's worth considering: it's possible to use metadata to set default facets for a table. If you do this for a table, then `.json` for that table will always calculate and return those facets - which may be an expensive and unnecessary operation.\r\n\r\nSo maybe we don't include `facet_results` in the JSON unless explicitly asked for in that case, but have a rule that `?_facet` implies `?_extra=facet_results`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1385805702", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1385805702, "node_id": "IC_kwDOBm6k_c5SmbeG", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-17T17:50:17Z", "updated_at": "2023-01-17T17:50:17Z", "author_association": "OWNER", "body": "Or maybe have a `permissions` extra which includes `allow_execute_sql` and `private`? Could anything else go in there?", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1384752452", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1384752452, "node_id": "IC_kwDOBm6k_c5SiaVE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-17T02:14:41Z", "updated_at": "2023-01-17T02:15:58Z", "author_association": "OWNER", "body": "Thinking about `?_extra=` values just for the table JSON. The default shape will look like this:\r\n\r\n```json\r\n{\r\n \"ok\": true,\r\n \"rows\": [{\"id\": 1, \"name\": \"Name\"}],\r\n \"next\": null,\r\n}\r\n```\r\nThe table extras could be:\r\n\r\n- `count` - adds a `\"count\"` field with a full `count(*)` for that filtered table\r\n- `next_url` - the full URL to the next page\r\n- `columns` - adds `\"columns\": [\"id\", \"name\"]`\r\n- `expandable_columns` - a list of columns that can be expanded (note that `\"expanded_columns\": [...]` shows up automatically if the user passes any `?_label=` options, like on https://latest.datasette.io/fixtures/facetable.json?_label=_city_id ) - I'm tempted to rename this to `label_columns` and have it add both `label_columns` and `label_columns_selected` or similar.\r\n- `primary_keys` - a list of primary keys e.g. `[\"id\"]` - not sure what to do about `rowid` columns here\r\n- `query` - a `{\"sql\": \"select ...\", \"params\": {\"p0\": \"1\"}}` object\r\n- `units` - the units feature\r\n- `suggested_facets` - suggested facets\r\n- `metadata` - a `{\"metadata\": {\"source_url\": \"...\"}}` etc block - differs from current in that it would be nested in `\"metadata\": {...}`.\r\n\r\nStuff currently in https://latest.datasette.io/fixtures/facetable.json that is not yet covered by the above:\r\n```\r\n \"database\": \"fixtures\",\r\n \"table\": \"facetable\",\r\n \"is_view\": false,\r\n \"human_description_en\": \"where id = 1\",\r\n \"private\": false,\r\n \"allow_execute_sql\": true,\r\n \"query_ms\": 16.749476999393664,\r\n```\r\nI'm tempted to bundle `database`, `table`, `is_view` and `human_description_en` into one (not sure what to call it though, perhaps `display_details`?) - and then drop `allow_execute_sql` entirely and have `private` and `query_ms` as their own named extras.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1384743243", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1384743243, "node_id": "IC_kwDOBm6k_c5SiYFL", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-17T02:01:26Z", "updated_at": "2023-01-17T02:01:26Z", "author_association": "OWNER", "body": "I'm tempted NOT to document the JSON for the `/.json` page, simply because I'm not at all convinced that the current homepage design is the best possible use of that space - and I'd like to reserve the opportunity to redesign that in e.g. Datasette 1.1 without it being a breaking change to the documented JSON API.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1384742385", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1384742385, "node_id": "IC_kwDOBm6k_c5SiX3x", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-17T02:00:23Z", "updated_at": "2023-01-17T02:00:38Z", "author_association": "OWNER", "body": "I'm not actually too happy about how `/fixtures.json` currently entirely changes shape based on whether or not you pass a `?sql=` argument to it.\r\n\r\nMaybe I can fix that disparity with extras too?\r\n\r\nThe list of tables you see on `/fixtures.json` without the `?sql=` could become another extra. The HTML version of that page could know to request that extra by default.\r\n\r\nThis would also support running a SQL query but also returning a list of tables - which can be useful for building a SQL editor interface which hints at the tables that are available to the user - or even for generating the configuration needed by the CodeMirror editor's SQL completion, added in:\r\n- #1893", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/262#issuecomment-1384741055", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/262", "id": 1384741055, "node_id": "IC_kwDOBm6k_c5SiXi_", "user": {"value": 9599, "label": "simonw"}, "created_at": "2023-01-17T01:58:24Z", "updated_at": "2023-01-17T01:58:24Z", "author_association": "OWNER", "body": "As suggested in this issue:\r\n- #1721 \r\n\r\nThere are three parts of the Datasette API that need to support extras:\r\n\r\n- Table, e.g. https://latest.datasette.io/fixtures/facetable.json\r\n- Row, e.g. https://latest.datasette.io/fixtures/facetable/1.json\r\n- Query, e.g. https://latest.datasette.io/fixtures/neighborhood_search.json or https://latest.datasette.io/fixtures.json?sql=%0Aselect+_neighborhood%2C+facet_cities.name%2C+state%0Afrom+facetable%0A++++join+facet_cities%0A++++++++on+facetable._city_id+%3D+facet_cities.id%0Awhere+_neighborhood+like+%27%25%27+||+%3Atext+||+%27%25%27%0Aorder+by+_neighborhood%3B%0A&text=\r\n\r\nThere are two other pages I should consider though:\r\n\r\n- https://latest.datasette.io/.json - the JSON version of the https://latest.datasette.io/ homepage\r\n- https://latest.datasette.io/fixtures.json - note that this is different from the same URL with `?sql=...` appended to it. This is the index of tables in a specific database", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 323658641, "label": "Add ?_extra= mechanism for requesting extra properties in JSON"}, "performed_via_github_app": null}