Skip to main content

build_fts_prefix_query

Function build_fts_prefix_query 

Source
fn build_fts_prefix_query(query: &str) -> Option<String>
Expand description

Build a safe FTS5 prefix query from raw user input.

Every whitespace-separated token is emitted as a quoted phrase, so punctuation the user types (apostrophes in Bob's Burgers, hyphens in Spider-Man, the / in AC/DC) is treated as data rather than FTS5 operator syntax — unquoted, those characters make MATCH raise a syntax error and the whole search fails. The final token carries the * prefix operator so results appear while the user is still typing; earlier tokens are implicitly ANDed, which preserves the pre-existing matching semantics.

Returns None when the input holds nothing searchable (empty, or pure punctuation), so callers skip the query rather than handing FTS5 a string it will reject — search("") is a real call site, used to list all playlists.

TRACES: UR-065 | DR-108 | UT-111