{"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1319570586", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1319570586, "node_id": "IC_kwDOBm6k_c5Opwya", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-18T05:33:20Z", "updated_at": "2022-11-18T05:33:20Z", "author_association": "OWNER", "body": "One of the big changes still left to do for Datasette 1.0 is to unify the JSON representation with the context psssed to the templates (via an `?_extra=` mechanism to add extra context needed by the HTML templates), because a goal for 1.0 is for the template context to be a documented API contract such that custom templates won't break with future releases.\r\n\r\nAs such I expect to do quite a bit of refactoring and cleanup on how the template context works later on.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1319533445", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1319533445, "node_id": "IC_kwDOBm6k_c5OpnuF", "user": {"value": 95570, "label": "bgrins"}, "created_at": "2022-11-18T04:38:03Z", "updated_at": "2022-11-18T04:38:03Z", "author_association": "CONTRIBUTOR", "body": "Are you tracking the change to send the JSON over to the frontend separately or was that part of this? Something like this is probably pretty close https://github.com/bgrins/datasette/commit/8431c98850c7a552dbcde2a4dd0c3dc942a97d25#diff-0c93232bfd5477eeac96382e52769108b41433d960d5277ffcccf2f464e60abdR9", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1319478811", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1319478811, "node_id": "IC_kwDOBm6k_c5OpaYb", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-18T02:53:57Z", "updated_at": "2022-11-18T02:53:57Z", "author_association": "OWNER", "body": "I decided to just go for the view names, not their columns.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1319477721", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1319477721, "node_id": "IC_kwDOBm6k_c5OpaHZ", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-18T02:51:40Z", "updated_at": "2022-11-18T02:51:40Z", "author_association": "OWNER", "body": "Views aren't currently available in the `_internal` schema.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1319435374", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1319435374, "node_id": "IC_kwDOBm6k_c5OpPxu", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-18T01:33:30Z", "updated_at": "2022-11-18T01:33:30Z", "author_association": "OWNER", "body": "Just noticed that this isn't including views, which it should.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1319401843", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1319401843, "node_id": "IC_kwDOBm6k_c5OpHlz", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-18T00:42:03Z", "updated_at": "2022-11-18T00:42:23Z", "author_association": "OWNER", "body": "This function works even if the SQLite JSON functions are not available:\r\n\r\n```python\r\nasync def _table_columns(datasette, database_name):\r\n internal = datasette.get_database(\"_internal\")\r\n result = await internal.execute(\r\n \"select table_name, name from columns where database_name = ?\",\r\n [database_name],\r\n )\r\n table_columns = {}\r\n for row in result.rows:\r\n table_columns.setdefault(row[\"table_name\"], []).append(row[\"name\"])\r\n return table_columns\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1317840727", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1317840727, "node_id": "IC_kwDOBm6k_c5OjKdX", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:57:52Z", "updated_at": "2022-11-16T23:57:52Z", "author_association": "OWNER", "body": "In terms of permissions: if you have `execute-sql` permission for a database then it's OK for you to see the table columns for that database.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1317839781", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1317839781, "node_id": "IC_kwDOBm6k_c5OjKOl", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:56:47Z", "updated_at": "2022-11-16T23:56:47Z", "author_association": "OWNER", "body": "I'm going to call this `table_columns` in the template context (because `schema` might mean `CREATE TABLE ...`.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/1897#issuecomment-1317838892", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1897", "id": 1317838892, "node_id": "IC_kwDOBm6k_c5OjKAs", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:55:42Z", "updated_at": "2022-11-16T23:55:42Z", "author_association": "OWNER", "body": "Here's where the schema is hard-coded at the moment: https://github.com/simonw/datasette/blob/00e233d7a7f6443cb95fb5227c23580c48551cad/datasette/templates/_codemirror_foot.html#L2-L7\r\n\r\nI figured out how to extract that data from the `_internal` table in this comment: https://github.com/simonw/datasette/pull/1893#issuecomment-1317475720\r\n\r\nAlthough that used JSON functions which may (in a real edge-case) not be available in the version of SQLite that Datasette is running on, so probably going to use a regular SQL query and then assemble the JSON separately.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1452457263, "label": "Serve schema JSON to the SQL editor to enable autocomplete"}, "performed_via_github_app": null}