{"html_url": "https://github.com/simonw/datasette/issues/651#issuecomment-579675357", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/651", "id": 579675357, "node_id": "MDEyOklzc3VlQ29tbWVudDU3OTY3NTM1Nw==", "user": {"value": 2181410, "label": "clausjuhl"}, "created_at": "2020-01-29T09:45:00Z", "updated_at": "2021-07-14T19:26:06Z", "author_association": "NONE", "body": "Hi Simon\r\n\r\nThank you for adding the escape_function, but it does not work on my datasette-installation (0.33). I've added the following file to my datasette-dir: `/plugins/sql_functions.py`:\r\n\r\n```python\r\nfrom datasette import hookimpl\r\n\r\ndef escape_fts_query(query):\r\n bits = query.split()\r\n return ' '.join('\"{}\"'.format(bit.replace('\"', '')) for bit in bits)\r\n\r\n@hookimpl\r\ndef prepare_connection(conn):\r\n conn.create_function(\"escape_fts_query\", 1, escape_fts_query)`\r\n```\r\nIt has no effect on the standard queries to the tables though, as they still produce errors when including any characters like '-', '/', '+' or '?'\r\n\r\nDoes the function only work when using costum queries, where I can include the escape_fts-function explicitly in the sql-query?\r\n\r\nPS. I'm calling datasette with --plugins=plugins, and my other plugins work just fine.\r\nPPS. The fts5 virtual table is created with 'sqlite3' like so:\r\n\r\n`CREATE VIRTUAL TABLE \"cases_fts\" USING FTS5(\r\n title,\r\n subtitle,\r\n resume,\r\n suggestion,\r\n presentation,\r\n detail = full,\r\n content_rowid = 'id',\r\n content = 'cases',\r\n tokenize='unicode61', 'remove_diacritics 2', 'tokenchars \"-_\"'\r\n);`\r\n\r\nThanks!", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 539590148, "label": "fts5 syntax error when using punctuation"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/662#issuecomment-579864036", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/662", "id": 579864036, "node_id": "MDEyOklzc3VlQ29tbWVudDU3OTg2NDAzNg==", "user": {"value": 2181410, "label": "clausjuhl"}, "created_at": "2020-01-29T17:17:01Z", "updated_at": "2020-01-29T17:17:01Z", "author_association": "NONE", "body": "This is excellent news. I'll wait until version 0.34. It would be tiresome to rewrite all standard-queries into custom queries. Thank you!", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 556814876, "label": "Escape_fts5_query-hookimplementation does not work with queries to standard tables"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/datasette/issues/662#issuecomment-579798917", "issue_url": "https://api.github.com/repos/simonw/datasette/issues/662", "id": 579798917, "node_id": "MDEyOklzc3VlQ29tbWVudDU3OTc5ODkxNw==", "user": {"value": 2181410, "label": "clausjuhl"}, "created_at": "2020-01-29T15:08:57Z", "updated_at": "2020-01-29T15:08:57Z", "author_association": "NONE", "body": "Hi Simon\r\n\r\nThankt you for a quick reply. Here are a few examples of urls, where I search the 'cases_fts'-virtual table for tokens in the title-column. It returns the same results, wether the other query-params are present or not.\r\n\r\nSearching for sky\r\nhttp://localhost:8001/db-7596a4e/cases?_search_title=sky&year__gte=1997&year__lte=2017&_sort_desc=last_deliberation_date\r\nReturns searchresults\r\n\r\nSearching for sky*\r\nhttp://localhost:8001/db-7596a4e/cases?_search_title=sky*&year__gte=1997&year__lte=2017&_sort_desc=last_deliberation_date\r\nReturns searchresults\r\n\r\nSearching for sky-tog\r\nhttp://localhost:8001/db-7596a4e/cases?_search_title=sky-tog&year__gte=1997&year__lte=2017&_sort_desc=last_deliberation_date\r\nThrows: No such column: tog\r\n\r\nsearching for sky+\r\nhttp://localhost:8001/db-7596a4e/cases?_search_title=sky%2B&year__gte=1997&year__lte=2017&_sort_desc=last_deliberation_date\r\nThrows: Invalid SQL: fts5: syntax error near \"\"\r\n\r\nSearching for \"madpakke\" (including double quotes)\r\nhttp://localhost:8001/db-7596a4e/cases?_search_title=%22madpakke%22&year__gte=1997&year__lte=2017&_sort_desc=last_deliberation_date\r\nReturns searchresults even though 'madpakke' only appears in the fulltextindex without quotes\r\n\r\nAs I said, my other plugins work just fine, and I just copied your sql_functions.py from the datasette-repo.\r\n\r\nThanks!", "reactions": "{\"total_count\": 1, \"+1\": 1, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 556814876, "label": "Escape_fts5_query-hookimplementation does not work with queries to standard tables"}, "performed_via_github_app": null}