{"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317837416", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317837416, "node_id": "IC_kwDOBm6k_c5OjJpo", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:54:02Z", "updated_at": "2022-11-16T23:54:02Z", "author_association": "OWNER", "body": "I'm going to tackle #1897 in the next few minutes.\r\n\r\nTests failed due to Prettier check, just pushed a fix so it would ignore `.bundle.js` too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317831555", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317831555, "node_id": "IC_kwDOBm6k_c5OjIOD", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:47:13Z", "updated_at": "2022-11-16T23:47:13Z", "author_association": "OWNER", "body": "I'll open a follow-up issue to fix the schema.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317831425", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317831425, "node_id": "IC_kwDOBm6k_c5OjIMB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:47:05Z", "updated_at": "2022-11-16T23:47:05Z", "author_association": "OWNER", "body": "OK, let's do it! Thanks so much for this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317829214", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317829214, "node_id": "IC_kwDOBm6k_c5OjHpe", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:44:36Z", "updated_at": "2022-11-16T23:44:36Z", "author_association": "OWNER", "body": "Deployed that to https://datasette-pr-1893.vercel.app/fixtures - looks good to me!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317797044", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317797044, "node_id": "IC_kwDOBm6k_c5Oi_y0", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T23:08:34Z", "updated_at": "2022-11-16T23:08:34Z", "author_association": "OWNER", "body": "> I can push up a commit that uses the static fixtures schema for testing, but given that the query used to generate it is authed we would still need some work to make that work on live data, right?\r\n\r\nYeah, push that up. I'm happy to wire in the query right after we land this.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317746206", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317746206, "node_id": "IC_kwDOBm6k_c5OizYe", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T22:17:24Z", "updated_at": "2022-11-16T22:17:24Z", "author_association": "OWNER", "body": "Deployed 0a649e8f78c23e8db6869442eeb0dfe36a5443da: https://datasette-pr-1893.vercel.app/fixtures", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317744563", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317744563, "node_id": "IC_kwDOBm6k_c5Oiy-z", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T22:16:03Z", "updated_at": "2022-11-16T22:16:03Z", "author_association": "OWNER", "body": "Honestly I'm not too bothered if table names with weird characters don't work correctly here - I care about those in the Datasette `fixtures.db` database because Datasette aims to support ANY valid SQLite database, so I need stuff in the test suite that includes weird edge cases like this. But I would hope very few people actually create tables with spaces in their names, so it's not a huge concern to me if autocompletion doesn't work properly for those.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317475720", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317475720, "node_id": "IC_kwDOBm6k_c5OhxWI", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T18:25:16Z", "updated_at": "2022-11-16T18:25:16Z", "author_association": "OWNER", "body": "Here's a query that returns the exact JSON we need to pass to the schema:\r\n\r\nhttps://latest.datasette.io/_internal?sql=with+inner+as+%28%0D%0A++select%0D%0A++++table_name%2C%0D%0A++++json_group_array%28name%29+as+table_columns%0D%0A++from%0D%0A++++columns%0D%0A++where%0D%0A++++database_name+%3D+%3Adatabase%0D%0A++group+by%0D%0A++++table_name%0D%0A%29%0D%0Aselect%0D%0A++json_group_object%28table_name%2C+table_columns%29%0D%0Afrom%0D%0A++inner&database=fixtures\r\n\r\n```sql\r\nwith inner as (\r\n select\r\n table_name,\r\n json_group_array(name) as table_columns\r\n from\r\n columns\r\n where\r\n database_name = :database\r\n group by\r\n table_name\r\n)\r\nselect\r\n json_group_object(table_name, table_columns)\r\nfrom\r\n inner\r\n```\r\nReturns (after pretty-printing):\r\n```json\r\n{\r\n \"123_starts_with_digits\": [\r\n \"content\"\r\n ],\r\n \"Table With Space In Name\": [\r\n \"content\",\r\n \"pk\"\r\n ],\r\n \"attraction_characteristic\": [\r\n \"name\",\r\n \"pk\"\r\n ],\r\n \"binary_data\": [\r\n \"data\"\r\n ],\r\n \"complex_foreign_keys\": [\r\n \"f1\",\r\n \"f2\",\r\n \"f3\",\r\n \"pk\"\r\n ],\r\n \"compound_primary_key\": [\r\n \"content\",\r\n \"pk1\",\r\n \"pk2\"\r\n ],\r\n \"compound_three_primary_keys\": [\r\n \"content\",\r\n \"pk1\",\r\n \"pk2\",\r\n \"pk3\"\r\n ],\r\n \"custom_foreign_key_label\": [\r\n \"foreign_key_with_custom_label\",\r\n \"pk\"\r\n ],\r\n \"facet_cities\": [\r\n \"id\",\r\n \"name\"\r\n ],\r\n \"facetable\": [\r\n \"_city_id\",\r\n \"_neighborhood\",\r\n \"complex_array\",\r\n \"created\",\r\n \"distinct_some_null\",\r\n \"n\",\r\n \"on_earth\",\r\n \"pk\",\r\n \"planet_int\",\r\n \"state\",\r\n \"tags\"\r\n ],\r\n \"foreign_key_references\": [\r\n \"foreign_key_compound_pk1\",\r\n \"foreign_key_compound_pk2\",\r\n \"foreign_key_with_blank_label\",\r\n \"foreign_key_with_label\",\r\n \"foreign_key_with_no_label\",\r\n \"pk\"\r\n ],\r\n \"infinity\": [\r\n \"value\"\r\n ],\r\n \"no_primary_key\": [\r\n \"a\",\r\n \"b\",\r\n \"c\",\r\n \"content\"\r\n ],\r\n \"primary_key_multiple_columns\": [\r\n \"content\",\r\n \"content2\",\r\n \"id\"\r\n ],\r\n \"primary_key_multiple_columns_explicit_label\": [\r\n \"content\",\r\n \"content2\",\r\n \"id\"\r\n ],\r\n \"roadside_attraction_characteristics\": [\r\n \"attraction_id\",\r\n \"characteristic_id\"\r\n ],\r\n \"roadside_attractions\": [\r\n \"address\",\r\n \"latitude\",\r\n \"longitude\",\r\n \"name\",\r\n \"pk\",\r\n \"url\"\r\n ],\r\n \"searchable\": [\r\n \"name with . and spaces\",\r\n \"pk\",\r\n \"text1\",\r\n \"text2\"\r\n ],\r\n \"searchable_fts\": [\r\n \"__langid\",\r\n \"docid\",\r\n \"name with . and spaces\",\r\n \"searchable_fts\",\r\n \"text1\",\r\n \"text2\"\r\n ],\r\n \"searchable_fts_docsize\": [\r\n \"docid\",\r\n \"size\"\r\n ],\r\n \"searchable_fts_segdir\": [\r\n \"end_block\",\r\n \"idx\",\r\n \"leaves_end_block\",\r\n \"level\",\r\n \"root\",\r\n \"start_block\"\r\n ],\r\n \"searchable_fts_segments\": [\r\n \"block\",\r\n \"blockid\"\r\n ],\r\n \"searchable_fts_stat\": [\r\n \"id\",\r\n \"value\"\r\n ],\r\n \"searchable_tags\": [\r\n \"searchable_id\",\r\n \"tag\"\r\n ],\r\n \"select\": [\r\n \"and\",\r\n \"group\",\r\n \"having\",\r\n \"json\"\r\n ],\r\n \"simple_primary_key\": [\r\n \"content\",\r\n \"id\"\r\n ],\r\n \"sortable\": [\r\n \"content\",\r\n \"pk1\",\r\n \"pk2\",\r\n \"sortable\",\r\n \"sortable_with_nulls\",\r\n \"sortable_with_nulls_2\",\r\n \"text\"\r\n ],\r\n \"table/with/slashes.csv\": [\r\n \"content\",\r\n \"pk\"\r\n ],\r\n \"tags\": [\r\n \"tag\"\r\n ],\r\n \"units\": [\r\n \"distance\",\r\n \"frequency\",\r\n \"pk\"\r\n ]\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": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317465874", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317465874, "node_id": "IC_kwDOBm6k_c5Ohu8S", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T18:21:17Z", "updated_at": "2022-11-16T18:21:54Z", "author_association": "OWNER", "body": "I was worrying about the server-side overhead of collecting together all of the tables and column names for databases that might have hundreds of tables... but then I remember that I built the `_internal` table precisely for this kind of thing - so gathering all of that data should still only be a single SQL query against an in-memory database.\r\n\r\nhttps://latest.datasette.io/login-as-root and then visit this page for an example query: https://latest.datasette.io/_internal?sql=select%0D%0A++database_name%2C%0D%0A++table_name%2C%0D%0A++json_group_array%28name%29%0D%0Afrom%0D%0A++columns%0D%0Awhere%0D%0A++database_name+%21%3D+%27_internal%27%0D%0Agroup+by%0D%0A++database_name%2C%0D%0A++table_name\r\n\r\n```sql\r\nselect\r\n database_name,\r\n table_name,\r\n json_group_array(name)\r\nfrom\r\n columns\r\nwhere\r\n database_name != '_internal'\r\ngroup by\r\n database_name,\r\n table_name\r\n```\r\n\r\ndatabase_name | table_name | json_group_array(name)\r\n-- | -- | --\r\nextra_database | searchable | [\"pk\",\"text1\",\"text2\"]\r\nextra_database | searchable_fts | [\"__langid\",\"content\",\"docid\",\"searchable_fts\",\"text1\",\"text2\"]\r\nextra_database | searchable_fts_content | [\"c0text1\",\"c1text2\",\"c2content\",\"docid\"]\r\nextra_database | searchable_fts_segdir | [\"end_block\",\"idx\",\"leaves_end_block\",\"level\",\"root\",\"start_block\"]\r\nextra_database | searchable_fts_segments | [\"block\",\"blockid\"]\r\nfixtures | 123_starts_with_digits | [\"content\"]\r\nfixtures | Table With Space In Name | [\"content\",\"pk\"]\r\nfixtures | attraction_characteristic | [\"name\",\"pk\"]\r\nfixtures | binary_data | [\"data\"]\r\nfixtures | complex_foreign_keys | [\"f1\",\"f2\",\"f3\",\"pk\"]\r\nfixtures | compound_primary_key | [\"content\",\"pk1\",\"pk2\"]\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": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317456909", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317456909, "node_id": "IC_kwDOBm6k_c5OhswN", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T18:17:39Z", "updated_at": "2022-11-16T18:17:39Z", "author_association": "OWNER", "body": "Tiny feature request (since you're in this code already) - I keep hitting Command+Enter on my macOS keyboard to submit the query, but the correct shortcut is Shift+Enter. Would be great if both worked!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317452541", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317452541, "node_id": "IC_kwDOBm6k_c5Ohrr9", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T18:15:52Z", "updated_at": "2022-11-16T18:15:52Z", "author_association": "OWNER", "body": "Deployed latest copy with:\r\n```\r\ndatasette publish vercel fixtures.db \\\r\n --project datasette-pr-1893 \\\r\n --about 'PR 1893' \\\r\n --about_url https://github.com/simonw/datasette/pull/1893 \\\r\n --scope datasette \\\r\n --branch eccb1c6c781d69d8ec3c542ef65c78a4a0927a7c\r\n```\r\nhttps://datasette-pr-1893.vercel.app/fixtures\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1317449610", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1317449610, "node_id": "IC_kwDOBm6k_c5Ohq-K", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T18:14:28Z", "updated_at": "2022-11-16T18:14:28Z", "author_association": "OWNER", "body": "> I'm thinking of also adding `count` to the list since that's a common thing people would want to autocomplete. I notice BQ console highlights `count` in the same manner as other keywords like `select` as well.\r\n\r\nHuh, yeah we should definitely have `count` - surprised it's not on the list on https://www.sqlite.org/lang_keywords.html which is why we didn't get it from the GPT-3 generated schema.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316412234", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316412234, "node_id": "IC_kwDOBm6k_c5OdttK", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T06:00:39Z", "updated_at": "2022-11-16T06:01:36Z", "author_association": "OWNER", "body": "Should note though that this is a classic example of GPT-3 making stuff up in places.\r\n\r\n> current: Returns the current date, time, or timestamp\r\n\r\n`select current` throws an error for me: https://latest.datasette.io/_memory?sql=select+current\r\n\r\n`select current_date, current_time, current_timestamp` works though: https://latest.datasette.io/_memory?sql=select+current_date%2C+current_time%2C+current_timestamp\r\n\r\nSo let's drop `current` from the list. I'm OK with it though, I think it's likely good enough for the first attempt at this.\r\n\r\nWe should drop `temp` and `temporary` too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316401895", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316401895, "node_id": "IC_kwDOBm6k_c5OdrLn", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T05:50:40Z", "updated_at": "2022-11-16T05:50:40Z", "author_association": "OWNER", "body": "So I think our dialect (at least to start with) should be:\r\n\r\n```\r\n keywords:\r\n \"and as asc between by case cast current current_date current_time current_timestamp desc distinct each else escape except exists explain filter first for from full generated group having if in index inner intersect into isnull join last left like limit not null or order outer over pragma primary query raise range regexp right rollback row select set table temp temporary then to union unique using values view virtual when where\",\r\n // https://www.sqlite.org/datatype3.html\r\n types: \"null integer real text blob\",\r\n builtin:\r\n \"\"\r\n```\r\nI left `builtin` blank here because I don't think we need any of those things at all.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316400688", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316400688, "node_id": "IC_kwDOBm6k_c5Odq4w", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T05:49:31Z", "updated_at": "2022-11-16T05:49:31Z", "author_association": "OWNER", "body": "OK, I decided to play around with GPT-3 for this. https://beta.openai.com/playground\r\n\r\nI prompted:\r\n\r\n```\r\nFor each keyword say it it can be used in a SQLite select statement: and as asc between by case cast \r\ncross current current_date current_time current_timestamp desc detach distinct each else end escape \r\nexcept exclude exclusive exists explain fail filter first following for foreign from full generated glob \r\ngroup groups having if ignore immediate in index indexed initially inner insert instead intersect into \r\nis isnull join key last left like limit match materialized natural no not nothing notnull null nulls of \r\noffset on or order others outer over partition plan pragma preceding primary query raise range recursive \r\nreferences regexp reindex release rename replace restrict returning right rollback row rows savepoint \r\nselect set table temp temporary then ties to transaction trigger unbounded union unique update using \r\nvacuum values view virtual when where window with without\r\n\r\n- and: yes\r\n- as: yes\r\n- asc: yes\r\n- between: yes\r\n- by: yes\r\n- case: yes\r\n- cast: yes\r\n- current: yes\r\n- current_date: yes\r\n- current_time: yes\r\n- current_timestamp: yes\r\n- desc: yes\r\n- detach: no\r\n- distinct: yes\r\n- each: yes\r\n- else: yes\r\n- end: yes\r\n- escape: yes\r\n- except: no\r\n- exclude: yes\r\n- exclusive: no\r\n```\r\nHaving given it these examples I ran it a few times:\r\n```\r\n- exists: yes\r\n- explain: no\r\n- fail: no\r\n- filter: yes\r\n- first: yes\r\n- following: no\r\n- for: yes\r\n- foreign: no\r\n- from: yes\r\n- full: no\r\n- generated: no\r\n- glob: yes\r\n- group: yes\r\n- groups: no\r\n- having: yes\r\n- if: yes\r\n- ignore: no\r\n- immediate: no\r\n- in: yes\r\n- index: yes\r\n- indexed: no\r\n- initially: no\r\n- inner: no\r\n- insert: no\r\n- instead: no\r\n- intersect: no\r\n- into: yes\r\n- is: yes\r\n- isnull: yes\r\n- join: yes\r\n- key: no\r\n- last: yes\r\n- left: yes\r\n- like: yes\r\n- limit: yes\r\n- match: no\r\n- materialized: no\r\n-natural: yes\r\n- no: no\r\n- not: no\r\n- nothing: no\r\n- notnull: yes\r\n- null: yes\r\n- nulls: yes\r\n- of: no\r\n- offset: yes\r\n- on: yes\r\n- or: yes\r\n- order: yes\r\n- others: yes\r\n- outer: no\r\n- over: no\r\n- partition: no\r\n- pragma: no\r\n- preceding: no\r\n- primary: no\r\n- query: no\r\n- raise: no\r\n- range: no\r\n- recursive: no\r\n- references: no\r\n- regexp: yes\r\n- reindex: no\r\n- release: no\r\n- rename: no\r\n- replace: no\r\n- restrict: no\r\n- returning: yes\r\n- right: yes\r\n- rollback: no\r\n- row: yes\r\n- rows: no\r\n- savepoint: no\r\n- select: yes\r\n- set: no\r\n- table: yes\r\n- temp: yes\r\n- temporary: yes\r\n- then: yes\r\n- ties: no\r\n- to: yes\r\n- transaction: no\r\n- trigger: no\r\n- unbounded: no\r\n- union: yes\r\n- unique: yes\r\n- update: no\r\n- using: yes\r\n- vacuum: no\r\n- values: yes\r\n- view: yes\r\n- virtual: no\r\n- when: yes\r\n- where: yes\r\n- window: no\r\n- with: yes\r\n- without: no\r\n```\r\nI added this:\r\n```\r\nA space separated list of all of the keywords for which the answer was yes: \r\n```\r\nIt replied:\r\n```\r\nand as asc between by case cast current current_date current_time current_timestamp desc distinct each else escape except exists explain filter first for from full generated group having if in index inner intersect into isnull join last left like limit not null or order outer over pragma primary query raise range regexp right rollback row select set table temp temporary then to union unique using values view virtual when where\r\n```\r\nThen I tried doing this:\r\n```\r\nProduce a short summary of how each of those are used:\r\n\r\n- and:\r\n```\r\nThis kind of worked too! It ended up defining every keyword, not just the ones for which the \"is it used in select\" was \"yes\", but it gave me this list:\r\n\r\n> - and: Used to combine multiple conditions in a WHERE clause\r\n> - as: Rename a column or table in the output of a query\r\n> - asc: Sort results in ascending order\r\n> - between: Used in a WHERE clause to specify a range\r\n> - by: Specifies how to sort the results of a query\r\n> - case: Used to create different outputs based on conditions\r\n> - cast: Converts a value from one data type to another\r\n> - current: Returns the current date, time, or timestamp\r\n> - current_date: Returns the current date\r\n> - current_time: Returns the current time\r\n> - current_timestamp: Returns the current timestamp\r\n> - desc: Sort results in descending order\r\n> - distinct: Selects only unique values\r\n> - each: Used with aggregate functions\r\n> - else: Used with the CASE statement\r\n> - escape: Used to escape special characters in a string\r\n> - except: Returns all rows from the first query that are not in the second query\r\n> - exists: Used with subqueries\r\n> - explain: Analyzes a query and returns information about it\r\n> - fail: Used with the ON CONFLICT clause\r\n> - filter: Used to specify conditions for aggregate functions\r\n> - first: Used to specify conditions for aggregate functions\r\n> - following: Used with window functions\r\n> - for: Used to specify conditions for aggregate functions\r\n> - foreign: Creates a foreign key\r\n> - from: Specifies the table(s) to select data from\r\n> - full: Used with outer joins\r\n> - generated: Used with generated columns\r\n> - glob: Used to match a string with a pattern\r\n> - group: Groups together rows that have the same values\r\n> - groups: Used with aggregate functions\r\n> - having: Specifies conditions for groups\r\n> - if: Used with the ON CONFLICT clause\r\n> - ignore: Used with the ON CONFLICT clause\r\n> - immediate: Used with the ON CONFLICT clause\r\n> - in: Used to check if a value is in a list\r\n> - index: Creates an index on a column or columns\r\n> - indexed: Used with the ON CONFLICT clause\r\n> - initially: Used with the ON CONFLICT clause\r\n> - inner: Creates an inner join\r\n> - insert: Inserts new data into a table\r\n> - instead: Used with triggers\r\n> - intersect: Returns all rows that are in both queries\r\n> - into: Specifies the table to insert data into\r\n> - is: Used to compare values\r\n> - isnull: Checks if a value is null\r\n> - join: Joins two or more tables together\r\n> - key: Creates a primary key or unique key\r\n> - last: Used to specify conditions for aggregate functions\r\n> - left: Creates a left join\r\n> - like: Checks if a value matches a pattern\r\n> - limit: Specifies the maximum number of rows to return\r\n> - not: Negates a condition\r\n> - null: Specifies a null value\r\n> - nulls: Used with the ORDER BY clause\r\n> - of: Used with window functions\r\n> - offset: Specifies the number of rows to skip\r\n> - on: Specifies conditions for a join\r\n> - or: Checks if either condition is true\r\n> - order: Specifies how to sort the results of a query\r\n> - others: Used with the CASE statement\r\n> - outer: Creates an outer join\r\n> - over: Used with window functions\r\n> - partition: Used with window functions\r\n> - pragma: Used to query or change various internal settings\r\n> - preceding: Used with window functions\r\n> - primary: Creates a primary key\r\n> - query: Used with the ON CONFLICT clause\r\n> - raise: Used with the ON CONFLICT clause\r\n> - range: Used with window functions\r\n> - recursive: Used with common table expressions\r\n> - references: Creates a foreign key\r\n> - regexp: Checks if a value matches a regular expression\r\n> - reindex: Recreates an index\r\n> - release: Used with savepoints\r\n> - rename: Changes the name of a table or column\r\n> - replace: Inserts new data into a table or updates existing data\r\n> - restrict: Used with savepoints\r\n> - returning: Returns data from inserted or updated rows\r\n> - right: Creates a right join\r\n> - rollback: Rolls back a transaction\r\n> - row: Used with aggregate functions\r\n> - select: Selects data from a table\r\n> - set: Changes the value of a column\r\n> - table: Specifies the table(s) to select data from\r\n> - temp: Creates a temporary table\r\n> - temporary: Creates a temporary table\r\n> - then: Used with the CASE statement\r\n> - ties: Used with the ORDER BY clause\r\n> - to: Used with common table expressions\r\n> - transaction: Starts a transaction\r\n> - trigger: Creates a trigger\r\n> - unbounded: Used with window functions\r\n> - union: Returns all rows from both queries\r\n> - unique: Creates a unique constraint\r\n> - update: Updates existing data in a table\r\n> - using: Specifies the table(s) to join\r\n> - vacuum: Optimizes a database\r\n> - values: Specifies the values to insert into a table\r\n> - view: Creates a view\r\n> - virtual: Creates a virtual table\r\n> - when: Used with the CASE statement\r\n> - where: Specifies conditions for a query\r\n> - window: Used with window functions\r\n> - with: Specifies common table expressions used in a query\r\n> - without: Used with indexes", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316340865", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316340865, "node_id": "IC_kwDOBm6k_c5OdcSB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T04:49:30Z", "updated_at": "2022-11-16T04:49:43Z", "author_association": "OWNER", "body": "> The main issue is that we don't pass the relevant table data down to QueryView.\r\n\r\nIf you can come up with a static example JSON data structure example that does the right thing, I'm happy to refactor QueryView to make that available to the template - or even have a separate `fetch()` that grabs just the data needed for the autocomplete as a separate hit when the page loads (whichever has better performance implications). I'm working a fair amount in the view classes at the moment so adding this to that work would make sense.\r\n\r\n", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316294156", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316294156, "node_id": "IC_kwDOBm6k_c5OdQ4M", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T04:00:12Z", "updated_at": "2022-11-16T04:00:12Z", "author_association": "OWNER", "body": "Have you ever seen CodeMirror correctly auto-completing columns? I'm not entirely sure I believe that the feature works anywhere else.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316293353", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316293353, "node_id": "IC_kwDOBm6k_c5OdQrp", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T03:59:03Z", "updated_at": "2022-11-16T03:59:03Z", "author_association": "OWNER", "body": "Deployed a fresh copy:\r\n```\r\ndatasette publish vercel fixtures.db \\\r\n --branch b7b2942b13f9ea09cfa9f8c73e2869b9bd2349ae \\\r\n --project datasette-pr-1893 \\\r\n --about 'PR 1893' \\\r\n --about_url https://github.com/simonw/datasette/pull/1893 \\\r\n --scope datasette\r\n```\r\nhttps://datasette-pr-1893.vercel.app/fixtures", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316253186", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316253186, "node_id": "IC_kwDOBm6k_c5OdG4C", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T03:16:36Z", "updated_at": "2022-11-16T03:16:36Z", "author_association": "OWNER", "body": "Yeah I haven't written this down anywhere but Datasette definitely has an undocumented preference for lower-case SQL.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316236448", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316236448, "node_id": "IC_kwDOBm6k_c5OdCyg", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T03:04:57Z", "updated_at": "2022-11-16T03:04:57Z", "author_association": "OWNER", "body": "If you rebase from `main` you should get the fix for that test failure.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316232588", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316232588, "node_id": "IC_kwDOBm6k_c5OdB2M", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T03:00:04Z", "updated_at": "2022-11-16T03:00:04Z", "author_association": "OWNER", "body": "Oops, the tests are failing because of a test failure I introduced here:\r\n- #1890", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316231560", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316231560, "node_id": "IC_kwDOBm6k_c5OdBmI", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T02:59:00Z", "updated_at": "2022-11-16T02:59:00Z", "author_association": "OWNER", "body": "The resize handle doesn't appear on Mobile Safari on iPhone - I don't think that particularly matters though.\r\n\r\nThe textarea does get a weird border around it when focused on iPhone though.\r\n\r\nFocused:\r\n\r\n![BF34E8FB-E35C-4CAB-9BFB-8EEF7E29B16C_1_201_a](https://user-images.githubusercontent.com/9599/202072748-c85bab94-a039-4ed6-8185-3cac25c78ed3.jpeg)\r\n\r\nNot focused:\r\n\r\n![31A5CF38-D540-4A1A-8A7D-E29453D150F4_1_201_a](https://user-images.githubusercontent.com/9599/202072744-d9f0ea62-13b7-46ff-afe1-6d88d7fb8b53.jpeg)\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": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316227073", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316227073, "node_id": "IC_kwDOBm6k_c5OdAgB", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T02:54:22Z", "updated_at": "2022-11-16T02:54:32Z", "author_association": "OWNER", "body": "If you can get a version of this working with table and column autocompletion just using a static JavaScript object in the source code with the right tables and columns, I'm happy to take on the work of turning that static object into something that Datasette includes in the page itself with all of the correct values.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316141764", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316141764, "node_id": "IC_kwDOBm6k_c5OcrrE", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T01:26:59Z", "updated_at": "2022-11-16T01:26:59Z", "author_association": "OWNER", "body": "Resizing works great for me - and the page automatically sizes the editor to fit an existing query, e.g. on https://datasette-pr-1893.vercel.app/fixtures?sql=select+id%2C+content%2C+content2%0D%0A++from+primary_key_multiple_columns_explicit_label%0D%0A++order+by+id%0D%0A++limit+101", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316137982", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316137982, "node_id": "IC_kwDOBm6k_c5Ocqv-", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T01:23:47Z", "updated_at": "2022-11-16T01:23:47Z", "author_association": "OWNER", "body": "Autocomplete here looks promising (I've wanted that to work for years!), but it does currently show a whole bunch of suggestions which aren't part of the SQLite SQL dialect:\r\n\r\n![autocomplete](https://user-images.githubusercontent.com/9599/202060211-51ec9f45-bc52-459a-a729-27fc2faadff9.gif)\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/1893#issuecomment-1316135244", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/1893", "id": 1316135244, "node_id": "IC_kwDOBm6k_c5OcqFM", "user": {"value": 9599, "label": "simonw"}, "created_at": "2022-11-16T01:21:41Z", "updated_at": "2022-11-16T01:21:41Z", "author_association": "OWNER", "body": "I just deployed a demo instance like this (using the commit hash from this PR):\r\n\r\n```bash\r\ndatasette publish vercel fixtures.db \\\r\n --branch 544f7025900b78f63c34b9985522271ba5fd9c0f \\\r\n --project datasette-pr-1893 \\\r\n --scope datasette \\\r\n --about 'PR 1893' \\\r\n --about_url https://github.com/simonw/datasette/pull/1893\r\n```\r\nHere's the result: https://datasette-pr-1893.vercel.app/fixtures", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 1450363982, "label": "Upgrade to CodeMirror 6, add SQL autocomplete"}, "performed_via_github_app": null}