Fix minor issue in searchMessages

Co-authored-by: Fedor Indutny <79877362+indutny-signal@users.noreply.github.com>
This commit is contained in:
automated-signal 2024-02-27 11:10:02 -06:00 committed by GitHub
parent f777268b04
commit 694a196b2e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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