Skip to content

Commit f69d181

Browse files
committed
avoid passing empty query to FTS5 for sqlite backend (fixes #35)
1 parent 9989d01 commit f69d181

File tree

1 file changed

+4
-0
lines changed
  • lib/PerldocBrowser/Plugin/PerldocSearch

1 file changed

+4
-0
lines changed

lib/PerldocBrowser/Plugin/PerldocSearch/SQLite.pm

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ sub _pod_search ($c, $perl_version, $query, $limit = undef) {
6464
my @limit_param = defined $limit ? $limit : ();
6565
$query =~ s/"/""/g;
6666
$query = join ' ', map { qq{"$_"} } split ' ', $query;
67+
return [] unless length $query;
6768
return $c->sqlite->db->query(q{SELECT "name", "abstract",
6869
snippet("pods_index", 3, '__HEADLINE_START__', '__HEADLINE_STOP__', ' ... ', 36) AS "headline"
6970
FROM "pods_index" WHERE "rowid" IN (SELECT "id" FROM "pods" WHERE "perl_version" = ? AND "contents" != '')
@@ -76,6 +77,7 @@ sub _function_search ($c, $perl_version, $query, $limit = undef) {
7677
my @limit_param = defined $limit ? $limit : ();
7778
$query =~ s/"/""/g;
7879
$query = join ' ', map { qq{"$_"} } split ' ', $query;
80+
return [] unless length $query;
7981
return $c->sqlite->db->query(q{SELECT "name",
8082
snippet("functions_index", 1, '__HEADLINE_START__', '__HEADLINE_STOP__', ' ... ', 36) AS "headline"
8183
FROM "functions_index" WHERE "rowid" IN (SELECT "id" FROM "functions" WHERE "perl_version" = ? AND "description" != '')
@@ -88,6 +90,7 @@ sub _faq_search ($c, $perl_version, $query, $limit = undef) {
8890
my @limit_param = defined $limit ? $limit : ();
8991
$query =~ s/"/""/g;
9092
$query = join ' ', map { qq{"$_"} } split ' ', $query;
93+
return [] unless length $query;
9194
return $c->sqlite->db->query(q{SELECT "perlfaq", "question",
9295
snippet("faqs_index", 1, '__HEADLINE_START__', '__HEADLINE_STOP__', ' ... ', 36) AS "headline"
9396
FROM "faqs_index" WHERE "rowid" IN (SELECT "id" FROM "faqs" WHERE "perl_version" = ? AND "answer" != '')
@@ -100,6 +103,7 @@ sub _perldelta_search ($c, $perl_version, $query, $limit = undef) {
100103
my @limit_param = defined $limit ? $limit : ();
101104
$query =~ s/"/""/g;
102105
$query = join ' ', map { qq{"$_"} } split ' ', $query;
106+
return [] unless length $query;
103107
return $c->sqlite->db->query(q{SELECT "perldelta", "heading",
104108
snippet("perldeltas_index", 1, '__HEADLINE_START__', '__HEADLINE_STOP__', ' ... ', 36) AS "headline"
105109
FROM "perldeltas_index" WHERE "rowid" IN (SELECT "id" FROM "perldeltas" WHERE "perl_version" = ? AND "contents" != '')

0 commit comments

Comments
 (0)