{"html_url": "https://github.com/simonw/datasette/issues/577#issuecomment-581758728", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/577", "id": 581758728, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MTc1ODcyOA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T06:11:53Z", "updated_at": "2020-02-04T06:11:53Z", "author_association": "OWNER", "body": "For the moment I'm going to move it to `async def render_template()` on `datasette` but otherwise keep the implementation the same.\r\n\r\nThe new signature will be:\r\n\r\n async def render_template(self, template, context=None, request=None, view_name=None):\r\n\r\n`template` can be a list of strings or a single string. If a list of strings a template will be selected from them.\r\n\r\nI'll reconsider the large list of default context variables later on in a separate ticket.", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 497171390, "label": "Utility mechanism for plugins to render templates"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/664#issuecomment-581768760", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/664", "id": 581768760, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MTc2ODc2MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T06:54:12Z", "updated_at": "2020-02-04T06:54:12Z", "author_association": "OWNER", "body": "Needs documentation.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 559522877, "label": "Datasette.render_template() method"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/664#issuecomment-581770979", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/664", "id": 581770979, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MTc3MDk3OQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T07:02:37Z", "updated_at": "2020-02-04T07:02:37Z", "author_association": "OWNER", "body": "More importantly, I need to prototype up a plugin that actually uses this method - probably `datasette-upload-csvs` - to make sure it serves its purpose.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 559522877, "label": "Datasette.render_template() method"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/664#issuecomment-581988901", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/664", "id": 581988901, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MTk4ODkwMQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T16:17:55Z", "updated_at": "2020-02-04T16:17:55Z", "author_association": "OWNER", "body": "It doesn't make sense for extra body scripts to be available for all template renders (including from plugins) but extra CSS and JS to only be handled by the BaseView render method - especially since extra body scripts are likely to depend on extra JS files.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 559522877, "label": "Datasette.render_template() method"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/664#issuecomment-582089909", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/664", "id": 582089909, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjA4OTkwOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T20:03:07Z", "updated_at": "2020-02-04T20:03:07Z", "author_association": "OWNER", "body": "I'm going to ship this without documentation, get a couple of plugins out that use it and then add documentation once I'm confident it's right.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 559522877, "label": "Datasette.render_template() method"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/664#issuecomment-582092019", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/664", "id": 582092019, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjA5MjAxOQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T20:08:22Z", "updated_at": "2020-02-04T20:08:22Z", "author_association": "OWNER", "body": "See #576 for existing ticket covering Datasette class documentation.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 559522877, "label": "Datasette.render_template() method"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582141086", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582141086, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjE0MTA4Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T22:12:00Z", "updated_at": "2020-02-04T22:12:00Z", "author_association": "OWNER", "body": "You may well be right there! Let's add a test that demonstrates it.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582141626", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582141626, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjE0MTYyNg==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T22:13:31Z", "updated_at": "2020-02-04T22:13:31Z", "author_association": "OWNER", "body": "Looks like SQLite supports `/* ... */` style comments as well. I don't think supporting those should be a requirement to land this though. https://www.sqlite.org/lang_comment.html", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582100643", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582100643, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjEwMDY0Mw==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T20:29:56Z", "updated_at": "2020-02-04T20:29:56Z", "author_association": "OWNER", "body": "I think there's one nasty edge-case here that we need to worry about: SQLite allows newlines inside of single quoted strings and I've actually started using that in quite a few places - it's great for [embedding markdown in a string](https://github.com/simonw/datasette-render-markdown) for example.\r\n\r\nThe way you're stripping comments right now splits on newlines and removes any lines that start with `--`. I believe that will mangle the following example:\r\n\r\n```sql\r\nselect '# Hello there\r\n\r\n* This is a list\r\n* of items\r\n--\r\n[And a link](https://github.com/simonw/datasette-render-markdown).'\r\nas demo_markdown\r\n```", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582101530", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582101530, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjEwMTUzMA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T20:32:11Z", "updated_at": "2020-02-04T20:32:11Z", "author_association": "OWNER", "body": "This is the kind of problem that has made me think that Datasette would really benefit from including a smart SQLite-syntax SQL parser.\r\n\r\nWriting one is a bit of a challenge though! There's an example (derived from SQLite SELECT statements) included in pyparsing here but I've not spent much time evaluating it: https://github.com/pyparsing/pyparsing/blob/master/examples/select_parser.py", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/665#issuecomment-582103280", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/665", "id": 582103280, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjEwMzI4MA==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T20:36:48Z", "updated_at": "2020-02-04T20:36:48Z", "author_association": "OWNER", "body": "pyparsing has an example based on SQLite SELECT statements: https://github.com/pyparsing/pyparsing/blob/8d9ab59a2b2767ad56c9b852c325075113718c0a/examples/select_parser.py\r\n\r\nhttps://github.com/lark-parser/lark is a relatively new (less than two years old) parsing library that looks promising too.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 559964149, "label": "Introduce a SQL statement parser in Python"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582103856", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582103856, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjEwMzg1Ng==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2020-02-04T20:38:18Z", "updated_at": "2020-02-04T20:38:18Z", "author_association": "OWNER", "body": "We can probably solve this without a SQL parser though. Really all we care about here is that if the FIRST lines of the statement begin with `--` we ignore them and only validate the statement starting from the first non-commented line. I think we can do that without single quoted strings causing us confusion.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582105810", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582105810, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjEwNTgxMA==", "user": {"value": 418191, "label": "jaywgraves"}, "created_at": "2020-02-04T20:43:01Z", "updated_at": "2020-02-04T20:43:01Z", "author_association": "CONTRIBUTOR", "body": "I *think* the existing code will be OK even if I strip the lines in the middle of a new line delimited string.\r\n\r\nIt's only used for the validation, SQLite handles the `--` just fine and the whole SQL textarea still gets sent once it passes validation.\r\n\r\nI can add your test case to my branch later this evening though.\r\n", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/pull/653#issuecomment-582106085", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/653", "id": 582106085, "node_id": "MDEyOklzc3VlQ29tbWVudDU4MjEwNjA4NQ==", "user": {"value": 418191, "label": "jaywgraves"}, "created_at": "2020-02-04T20:43:43Z", "updated_at": "2020-02-04T20:43:43Z", "author_association": "CONTRIBUTOR", "body": "but this also doesn't have to land at all if it doesn't match your use case. ", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 541331755, "label": "allow leading comments in SQL input field"}, "performed_via_github_app": null}