mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Fix WHERE clause for keyword search queries with empty keywords
When the keyword parameter is empty, the AND clause has to be omitted, otherwise we get an SQL syntax error: ... WHERE PackageBases.PackagerUID IS NOT NULL AND () ... This got broken in commit 9e30013aa4fc6ce3a3c9f6f83a6fe789c1fc2456 Author: Kevin Morris <kevr.gtalk@gmail.com> Date: Sun Jul 5 18:19:06 2020 -0700 Support conjunctive keyword search in RPC interface Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
3062a78a92
commit
bc972089a1
1 changed files with 5 additions and 5 deletions
|
@ -697,9 +697,7 @@ function pkg_search_page($params, $show_headers=true, $SID="") {
|
||||||
}
|
}
|
||||||
elseif (isset($params["SeB"]) && $params["SeB"] == "k") {
|
elseif (isset($params["SeB"]) && $params["SeB"] == "k") {
|
||||||
/* Search by name. */
|
/* Search by name. */
|
||||||
$q_where .= "AND (";
|
|
||||||
$q_where .= construct_keyword_search($dbh, $params['K'], false, true);
|
$q_where .= construct_keyword_search($dbh, $params['K'], false, true);
|
||||||
$q_where .= ") ";
|
|
||||||
}
|
}
|
||||||
elseif (isset($params["SeB"]) && $params["SeB"] == "N") {
|
elseif (isset($params["SeB"]) && $params["SeB"] == "N") {
|
||||||
/* Search by name (exact match). */
|
/* Search by name (exact match). */
|
||||||
|
@ -711,9 +709,7 @@ function pkg_search_page($params, $show_headers=true, $SID="") {
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Keyword search (default). */
|
/* Keyword search (default). */
|
||||||
$q_where .= "AND (";
|
|
||||||
$q_where .= construct_keyword_search($dbh, $params['K'], true, true);
|
$q_where .= construct_keyword_search($dbh, $params['K'], true, true);
|
||||||
$q_where .= ") ";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -885,7 +881,11 @@ function construct_keyword_search($dbh, $keywords, $namedesc, $keyword=false) {
|
||||||
$op = "AND ";
|
$op = "AND ";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $q_keywords;
|
if (!empty($q_keywords)) {
|
||||||
|
$where_part = "AND (" . $q_keywords . ") ";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $where_part;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue