From 1868c6fb41c781bb9c02cde172b39ab630f28421 Mon Sep 17 00:00:00 2001 From: h7x4 Date: Wed, 9 Jul 2025 14:57:19 +0200 Subject: [PATCH] word_search: don't throw error on empty results --- lib/search/word_search/entry_id_query.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/search/word_search/entry_id_query.dart b/lib/search/word_search/entry_id_query.dart index 10c12de..28d58a8 100644 --- a/lib/search/word_search/entry_id_query.dart +++ b/lib/search/word_search/entry_id_query.dart @@ -77,7 +77,7 @@ String _filterFTSSensitiveCharacters(String word) { ${!countOnly ? 'LIMIT ?' : ''} ) - ${countOnly ? 'SELECT COUNT("entryId") AS count' : 'SELECT "entryId", MAX("score") AS "score"'} + SELECT ${countOnly ? 'COUNT("entryId") AS count' : '"entryId", MAX("score") AS "score"'} FROM ( SELECT * FROM fts_results UNION @@ -128,7 +128,7 @@ Future _queryKanjiCount( ); return connection .rawQuery(query, args) - .then((result) => result.first['count'] as int); + .then((result) => result.firstOrNull?['count'] as int? ?? 0); } Future> _queryKana( @@ -161,7 +161,7 @@ Future _queryKanaCount( ); return connection .rawQuery(query, args) - .then((result) => result.first['count'] as int); + .then((result) => result.firstOrNull?['count'] as int? ?? 0); } Future> _queryEnglish(