{"html_url": "https://github.com/simonw/sqlite-utils/issues/246#issuecomment-901353345", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/246", "id": 901353345, "node_id": "IC_kwDOCGYnMM41uY-B", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-18T18:57:13Z", "updated_at": "2021-08-18T18:57:13Z", "author_association": "OWNER", "body": "More documentation: https://sqlite-utils.datasette.io/en/latest/python-api.html#quoting-characters-for-use-in-search", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 831751367, "label": "Escaping FTS search strings"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/246#issuecomment-901345800", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/246", "id": 901345800, "node_id": "IC_kwDOCGYnMM41uXII", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-08-18T18:44:48Z", "updated_at": "2021-08-18T18:44:48Z", "author_association": "OWNER", "body": "The `db.quote_fts(value)` method from #247 can now be used for this - documentation here: https://sqlite-utils.datasette.io/en/latest/reference.html#sqlite_utils.db.Database.quote_fts\r\n\r\nI'll be adding further improvements relating to this (a `table.search(q, quote=True)` parameter) in #296.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 831751367, "label": "Escaping FTS search strings"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/246#issuecomment-801816980", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/246", "id": 801816980, "node_id": "MDEyOklzc3VlQ29tbWVudDgwMTgxNjk4MA==", "user": {"value": 37962604, "label": "polyrand"}, "created_at": "2021-03-18T10:40:32Z", "updated_at": "2021-03-18T10:43:04Z", "author_association": "NONE", "body": "I have found a similar problem, but I only when using that type of query (with `*` for doing a prefix search). I'm also building something on top of FTS5/sqlite-utils, and the way I decided to handle it was creating a specific function for prefixes. According to [the docs](https://www2.sqlite.org/fts5.html#fts5_prefix_queries), the query can be done in this 2 ways:\r\n\r\n```sql\r\n... MATCH '\"one two thr\" * '\r\n... MATCH 'one + two + thr*'\r\n```\r\n\r\nI thought I could build a query like the first one using this function:\r\n\r\n```python\r\ndef prefix(query: str):\r\n return f'\"{query}\" *'\r\n```\r\n\r\nAnd then I use the output of that function as the query parameter for the standard `.search()` method in sqlite-utils.\r\n\r\nHowever, my use case is different because I'm the one \"deciding\" when to use a prefix search, not the end user. I also haven't done many tests, but maybe you found that useful. One thing I could think of is checking if the query has an `*` at the end, remove it and build the prefix query using the function above.\r\n\r\nThis is just for prefix queries, I think having the escaping function is still useful for other use cases.", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 831751367, "label": "Escaping FTS search strings"}, "performed_via_github_app": null} {"html_url": "https://github.com/simonw/sqlite-utils/issues/246#issuecomment-799479175", "issue_url": "https://api.github.com/repos/simonw/sqlite-utils/issues/246", "id": 799479175, "node_id": "MDEyOklzc3VlQ29tbWVudDc5OTQ3OTE3NQ==", "user": {"value": 9599, "label": "simonw"}, "created_at": "2021-03-15T14:47:31Z", "updated_at": "2021-03-15T14:47:31Z", "author_association": "OWNER", "body": "This is a smart feature. I have something that does this in Datasette, extracting it out to `sqlite-utils` makes a lot of sense.\r\n\r\nhttps://github.com/simonw/datasette/blob/8e18c7943181f228ce5ebcea48deb59ce50bee1f/datasette/utils/__init__.py#L818-L829", "reactions": "{\"total_count\": 0, \"+1\": 0, \"-1\": 0, \"laugh\": 0, \"hooray\": 0, \"confused\": 0, \"heart\": 0, \"rocket\": 0, \"eyes\": 0}", "issue": {"value": 831751367, "label": "Escaping FTS search strings"}, "performed_via_github_app": null}