-
-
Notifications
You must be signed in to change notification settings - Fork 644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Escape_fts5_query-hookimplementation does not work with queries to standard tables #662
Comments
Can you share the exact queries you're having trouble with? The SQL itself or even just the full URL to the page (it doesn't matter if it's to a Datasette instance that isn't available online - I just need to see the URL parameters). |
Hi Simon Thankt 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. Searching for sky Searching for sky* Searching for sky-tog searching for sky+ Searching for "madpakke" (including double quotes) As I said, my other plugins work just fine, and I just copied your sql_functions.py from the datasette-repo. Thanks! |
I think I see what's happening here. Adding the new plugin isn't quite enough: the change I made to master also alters the table view code to call the new function: 3c861f3#diff-5e0ffd62fced7d46339b9b2cd167c2f9 If you add the escape function as a plugin in Datasette 0.33 you will have to use a custom SQL query to run it, like this: Or you can hold out for Datasette 0.34 which will have this fix and will hopefully ship within the next 24 hours. |
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! |
I just shipped 0.34: https://datasette.readthedocs.io/en/stable/changelog.html#v0-34 |
Hi Simon
Thank 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:
`from datasette import hookimpl
def escape_fts_query(query):
bits = query.split()
return ' '.join('"{}"'.format(bit.replace('"', '')) for bit in bits)
@hookimpl
def prepare_connection(conn):
conn.create_function("escape_fts_query", 1, escape_fts_query)`
It has no effect on the standard queries to the tables though, as they still produce errors when including any characters like '-', '/', '+' or '?'
Does the function only work when using costum queries, where I can include the escape_fts-function explicitly in the sql-query?
PS. I'm calling datasette with --plugins=plugins, and my other plugins work just fine.
PPS. The fts5 virtual table is created with 'sqlite3' like so:
CREATE VIRTUAL TABLE "cases_fts" USING FTS5( title, subtitle, resume, suggestion, presentation, detail = full, content_rowid = 'id', content = 'cases', tokenize='unicode61', 'remove_diacritics 2', 'tokenchars "-_"' );
Thanks!
Originally posted by @clausjuhl in #651 (comment)
The text was updated successfully, but these errors were encountered: