summaryrefslogtreecommitdiffstats
path: root/Bugzilla/DB.pm
diff options
context:
space:
mode:
authormyk%mozilla.org <>2005-07-15 11:05:08 +0200
committermyk%mozilla.org <>2005-07-15 11:05:08 +0200
commit5a7981bbfcf51569e5f59fd75d89ea838f681e75 (patch)
treeb6115a27a2ab19e0b604bdf111c7cf305a17cb13 /Bugzilla/DB.pm
parent93cc71342eebb7aa6211b446ecc64049c0f3dc1e (diff)
downloadbugzilla-5a7981bbfcf51569e5f59fd75d89ea838f681e75.tar.gz
bugzilla-5a7981bbfcf51569e5f59fd75d89ea838f681e75.tar.xz
Fix for bug 232612: enables boolean mode fulltext searches for better searching capabilities in the "Find a Specific Bug" page;
r=lpsolit
Diffstat (limited to 'Bugzilla/DB.pm')
-rw-r--r--Bugzilla/DB.pm25
1 files changed, 13 insertions, 12 deletions
diff --git a/Bugzilla/DB.pm b/Bugzilla/DB.pm
index 76e090d6c..f3b9e4ed9 100644
--- a/Bugzilla/DB.pm
+++ b/Bugzilla/DB.pm
@@ -257,22 +257,23 @@ sub sql_fulltext_search {
# This is as close as we can get to doing full text search using
# standard ANSI SQL, without real full text search support. DB specific
- # modules shoud override this, as this will be always much slower.
-
- # the text is already sql-quoted, so we need to remove the quotes first
- my $quote = substr($self->quote(''), 0, 1);
- $text = $1 if ($text =~ /^$quote(.*)$quote$/);
+ # modules should override this, as this will be always much slower.
# make the string lowercase to do case insensitive search
my $lower_text = lc($text);
- # split the text we search for to separate words
+ # split the text we search for into separate words
my @words = split(/\s+/, $lower_text);
- # search for occurence of all specified words in the column
- return "CASE WHEN (LOWER($column) LIKE ${quote}%" .
- join("%${quote} AND LOWER($column) LIKE ${quote}%", @words) .
- "%${quote}) THEN 1 ELSE 0 END";
+ # surround the words with wildcards and SQL quotes so we can use them
+ # in LIKE search clauses
+ @words = map($self->quote("%$_%"), @words);
+
+ # turn the words into a set of LIKE search clauses
+ @words = map("LOWER($column) LIKE $_", @words);
+
+ # search for occurrences of all specified words in the column
+ return "CASE WHEN (" . join(" AND ", @words) . ") THEN 1 ELSE 0 END";
}
#####################################################################
@@ -1159,12 +1160,12 @@ formatted SQL command have prefix C<sql_>. All other methods have prefix C<bz_>.
specified text on a given column.
There is a ANSI SQL version of this method implemented using
LIKE operator, but it's not a real full text search. DB specific
- modules shoud override this, as this generic implementation will
+ modules should override this, as this generic implementation will
be always much slower. This generic implementation returns
'relevance' as 0 for no match, or 1 for a match.
Params: $column = name of column to search (scalar)
$text = text to search for (scalar)
- Returns: formatted SQL for for full text search
+ Returns: formatted SQL for full text search
=item C<sql_istrcmp>