From bbf04f2fbc366478b15dfbca21008ee11e382496 Mon Sep 17 00:00:00 2001 From: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com> Date: Tue, 27 Feb 2024 08:11:49 -0800 Subject: [PATCH] Fix minor issue in searchMessages --- ts/sql/Server.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/ts/sql/Server.ts b/ts/sql/Server.ts index 03cc4ba62..563da9808 100644 --- a/ts/sql/Server.ts +++ b/ts/sql/Server.ts @@ -1762,6 +1762,11 @@ async function searchMessages({ .map(token => `"${token.replace(/"/g, '""')}"*`) .join(' '); + // FTS5 is not happy about empty "MATCH" so short-circuit early. + if (!normalizedQuery) { + return []; + } + // sqlite queries with a join on a virtual table (like FTS5) are de-optimized // and can't use indices for ordering results. Instead an in-memory index of // the join rows is sorted on the fly, and this becomes substantially