summaryrefslogtreecommitdiffstats
path: root/Bugzilla/Search.pm
diff options
context:
space:
mode:
authormkanat%kerio.com <>2005-03-09 08:23:30 +0100
committermkanat%kerio.com <>2005-03-09 08:23:30 +0100
commit5be75754f810eb414b666f3894e2dbf8943e3f0f (patch)
tree5c91e75fa2aaf9ad93e570396834d161b1aedfb1 /Bugzilla/Search.pm
parent3f4abbd8d47883c52cdbd25ce308fe7d638f25ce (diff)
downloadbugzilla-5be75754f810eb414b666f3894e2dbf8943e3f0f.tar.gz
bugzilla-5be75754f810eb414b666f3894e2dbf8943e3f0f.tar.xz
Bug 281582: Replace CONCAT and MATCH with Bugzilla::DB function call (Note: This patch also creates a database-agnostic fulltext search method.)
Patch By Tomas Kopal <Tomas.Kopal@altap.cz> r=mkanat, a=myk
Diffstat (limited to 'Bugzilla/Search.pm')
-rw-r--r--Bugzilla/Search.pm26
1 files changed, 15 insertions, 11 deletions
diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm
index 775778a9d..c38d07054 100644
--- a/Bugzilla/Search.pm
+++ b/Bugzilla/Search.pm
@@ -545,14 +545,14 @@ sub init {
# "content" is an alias for columns containing text for which we
# can search a full-text index and retrieve results by relevance,
# currently just bug comments (and summaries to some degree).
- # There's only one way to search a full-text index
- # ("MATCH (...) AGAINST (...)"), so we only accept the "matches"
- # operator, which is specific to full-text index searches.
+ # There's only one way to search a full-text index, so we only
+ # accept the "matches" operator, which is specific to full-text
+ # index searches.
# Add the longdescs table to the query so we can search comments.
my $table = "longdescs_$chartid";
- push(@supptables, "INNER JOIN longdescs $table ON bugs.bug_id " .
- "= $table.bug_id");
+ push(@supptables, "INNER JOIN longdescs AS $table " .
+ "ON bugs.bug_id = $table.bug_id");
if (Param("insidergroup")
&& !&::UserInGroup(Param("insidergroup")))
{
@@ -563,11 +563,13 @@ sub init {
# $term1 searches comments.
# $term2 searches summaries, which contributes to the relevance
# ranking in SELECT but doesn't limit which bugs get retrieved.
- my $term1 = "MATCH($table.thetext) AGAINST(".&::SqlQuote($v).")";
- my $term2 = "MATCH(bugs.short_desc) AGAINST(".&::SqlQuote($v).")";
+ my $term1 = $dbh->sql_fulltext_search("${table}.thetext",
+ ::SqlQuote($v));
+ my $term2 = $dbh->sql_fulltext_search("bugs.short_desc",
+ ::SqlQuote($v));
# The term to use in the WHERE clause.
- $term = $term1;
+ $term = "$term1 > 0";
# In order to sort by relevance (in case the user requests it),
# we SELECT the relevance value and give it an alias so we can
@@ -770,9 +772,11 @@ sub init {
push(@supptables, "LEFT JOIN flagtypes $flagtypes " .
"ON $flags.type_id = $flagtypes.id");
- # Generate the condition by running the operator-specific function.
- # Afterwards the condition resides in the global $term variable.
- $ff = "CONCAT($flagtypes.name, $flags.status)";
+ # Generate the condition by running the operator-specific
+ # function. Afterwards the condition resides in the global $term
+ # variable.
+ $ff = $dbh->sql_string_concat("${flagtypes}.name",
+ "$flags.status");
&{$funcsbykey{",$t"}};
# If this is a negative condition (f.e. flag isn't "review+"),