From f8543b2ba4cb5b48c861fbcde4e95065693be6a1 Mon Sep 17 00:00:00 2001 From: "justdave%syndicomm.com" Date: Sat, 2 Jun 2001 04:02:13 +0000 Subject: [PATCH] Fix for bug 65190: add comparison type "all words as substrings" and "any words as substrings" to the text fields in query.cgi Patch by Andreas Franke r= justdave@syndicomm.com git-svn-id: svn://10.0.0.236/trunk@96226 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/buglist.cgi | 28 +++++++++++++++++++++++++++ mozilla/webtools/bugzilla/query.cgi | 6 +++++- 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/mozilla/webtools/bugzilla/buglist.cgi b/mozilla/webtools/bugzilla/buglist.cgi index 8bc12b72e81..b99afefe9ca 100755 --- a/mozilla/webtools/bugzilla/buglist.cgi +++ b/mozilla/webtools/bugzilla/buglist.cgi @@ -21,6 +21,7 @@ # Contributor(s): Terry Weissman # Dan Mosedale # Stephan Niemz +# Andreas Franke use diagnostics; use strict; @@ -107,6 +108,21 @@ sub GetByWordList { return \@list; } +# +# support for "any/all/nowordssubstr" comparison type ("words as substrings") +# +sub GetByWordListSubstr { + my ($field, $strs) = (@_); + my @list; + + foreach my $word (split(/[\s,]+/, $strs)) { + if ($word ne "") { + push(@list, "INSTR(LOWER($field), " . lc(SqlQuote($word)) . ")"); + } + } + + return \@list; +} sub Error { @@ -491,6 +507,18 @@ sub GenerateSQL { } $term = join(" OR ", @list); }, + ",anywordssubstr" => sub { + $term = join(" OR ", @{GetByWordListSubstr($ff, $v)}); + }, + ",allwordssubstr" => sub { + $term = join(" AND ", @{GetByWordListSubstr($ff, $v)}); + }, + ",nowordssubstr" => sub { + my @list = @{GetByWordListSubstr($ff, $v)}; + if (@list) { + $term = "NOT (" . join(" OR ", @list) . ")"; + } + }, ",anywords" => sub { $term = join(" OR ", @{GetByWordList($ff, $v)}); }, diff --git a/mozilla/webtools/bugzilla/query.cgi b/mozilla/webtools/bugzilla/query.cgi index f9822bd5fe2..067f760369f 100755 --- a/mozilla/webtools/bugzilla/query.cgi +++ b/mozilla/webtools/bugzilla/query.cgi @@ -703,10 +703,12 @@ sub StringSearch {