question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Escape_fts5_query-hookimplementation does not work with queries to standard tables

See original GitHub issue

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 https://github.com/simonw/datasette/issues/651#issuecomment-579675357_

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
simonwcommented, Jan 30, 2020
1reaction
clausjuhlcommented, Jan 29, 2020

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Sqlite FTS5 punctuation marks not working in select query
Since i'm using ' : & characters within the search text, these queries are giving me errors. I have tried using escape characters(\-backslash) ......
Read more >
SQLite FTS3 and FTS4 Extensions
If neither of these two query strategies can be used, all queries on FTS tables are implemented using a linear scan of the...
Read more >
Release History Of SQLite
The query planner now does a better job of optimizing virtual table accesses ... Do not attempt to use the strchrnul() function from...
Read more >
Diff - platform/external/sqlite - Google Git
Fix for ticket ac661962a2aeab3c331 * Fix a query planner problem that could ... table implementations may overload SQL functions by implementing +** the ......
Read more >
Full-text search - Datasette documentation
You can disable this escaping and use the advanced queries by adding ?_searchmode=raw to the table page query string. Configuring full-text search for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found