]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 554986: Add a "notmatches" search type, which allows the minus sign
authorMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 29 Mar 2010 21:17:54 +0000 (14:17 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 29 Mar 2010 21:17:54 +0000 (14:17 -0700)
operator to start working for bare words in Quicksearch again
r=LpSolit, a=LpSolit

Bugzilla/Search.pm
Bugzilla/Search/Quicksearch.pm
template/en/default/global/code-error.html.tmpl
template/en/default/global/field-descs.none.tmpl
template/en/default/list/list.html.tmpl
template/en/default/search/boolean-charts.html.tmpl

index 91cd7f73bb941a53b4f918c5be88f13d2a39ca2b..630cdd7d5a340c0a3c03f1d1a440fa1c8716d1c2 100644 (file)
@@ -612,7 +612,7 @@ sub init {
         "^long_?desc,changedby" => \&_long_desc_changedby,
         "^long_?desc,changedbefore" => \&_long_desc_changedbefore_after,
         "^long_?desc,changedafter" => \&_long_desc_changedbefore_after,
-        "^content,matches" => \&_content_matches,
+        "^content,(?:not)?matches" => \&_content_matches,
         "^content," => sub { ThrowUserError("search_content_without_matches"); },
         "^(?:deadline|creation_ts|delta_ts),(?:lessthan|greaterthan|equals|notequals),(?:-|\\+)?(?:\\d+)(?:[dDwWmMyY])\$" => \&_timestamp_compare,
         "^commenter,(?:equals|anyexact),(%\\w+%)" => \&_commenter_exact,
@@ -656,6 +656,7 @@ sub init {
         ",notregexp" => \&_notregexp,
         ",lessthan" => \&_lessthan,
         ",matches" => sub { ThrowUserError("search_content_without_matches"); },
+        ",notmatches" => sub { ThrowUserError("search_content_without_matches"); },
         ",greaterthan" => \&_greaterthan,
         ",anyexact" => \&_anyexact,
         ",anywordssubstr" => \&_anywordsubstr,
@@ -1415,8 +1416,8 @@ sub _long_desc_changedbefore_after {
 sub _content_matches {
     my $self = shift;
     my %func_args = @_;
-    my ($chartid, $supptables, $term, $groupby, $fields, $v) =
-        @func_args{qw(chartid supptables term groupby fields v)};
+    my ($chartid, $supptables, $term, $groupby, $fields, $t, $v) =
+        @func_args{qw(chartid supptables term groupby fields v)};
     my $dbh = Bugzilla->dbh;
     
     # "content" is an alias for columns containing text for which we
@@ -1443,19 +1444,21 @@ sub _content_matches {
 
     # The term to use in the WHERE clause.
     $$term = "$term1 > 0 OR $term2 > 0";
+    if ($$t =~ /not/i) {
+        $$term = "NOT($$term)";
+    }
     
     # In order to sort by relevance (in case the user requests it),
     # we SELECT the relevance value so we can add it to the ORDER BY
     # clause. Every time a new fulltext chart isadded, this adds more 
-    # terms to the relevance sql. (That doesn't make sense in
-    # "NOT" charts, but Bugzilla never uses those with fulltext
-    # by default.)
+    # terms to the relevance sql.
     #
     # We build the relevance SQL by modifying the COLUMNS list directly,
     # which is kind of a hack but works.
     my $current = COLUMNS->{'relevance'}->{name};
     $current = $current ? "$current + " : '';
-    my $select_term = "($current$rterm1 + $rterm2)";
+    # For NOT searches, we just add 0 to the relevance.
+    my $select_term = $$t =~ /not/ ? 0 : "($current$rterm1 + $rterm2)";
     COLUMNS->{'relevance'}->{name} = $select_term;
 }
 
index 3732be76d28edc35033173d5cbe1307bd98da84b..65dc085a79842fcd306b52fc64fad5afb8c4e8c3 100644 (file)
@@ -569,19 +569,10 @@ sub matchPrefixes {
 sub negateComparisonType {
     my $comparisonType = shift;
 
-    if ($comparisonType eq 'substring') {
-        return 'notsubstring';
-    }
-    elsif ($comparisonType eq 'anywords') {
+    if ($comparisonType eq 'anywords') {
         return 'nowords';
     }
-    elsif ($comparisonType eq 'regexp') {
-        return 'notregexp';
-    }
-    else {
-        # Don't know how to negate that
-        ThrowCodeError('unknown_comparison_type');
-    }
+    return "not$comparisonType";
 }
 
 # Add a boolean chart
index b8a87fb58b0c5015c0a77a1c98d59db0be0d991f..753695b2d5c4d58369bad1dc5794e0adf24e0808 100644 (file)
     An error occurred while preparing for a RADIUS authentication request:
     <code>[% errstr FILTER html %]</code>.
 
-  [% ELSIF error == "unknown_comparison_type" %]
-    Specified comparison type is not supported.
-
   [% ELSIF error == "request_queue_group_invalid" %]
     The group field <em>[% group FILTER html %]</em> is invalid.
 
index 4ada8c0665a87d9ee30c2f0a2d40294c6f7ffacd..0c17e570334c34d2fa7d27f41f1281aa2e950f9a 100644 (file)
@@ -49,6 +49,7 @@
   "changedto"      => "changed to",
   "changedby"      => "changed by",
   "matches"        => "matches",
+  "notmatches"      => "does not match",
 } %]
 
 [% field_types = { ${constants.FIELD_TYPE_UNKNOWN}       => "Unknown Type",
index 8a820810338b8753b4a42527366247822e7854b1..696e868a49593d90aa4254d7ad181a4ebf092464 100644 (file)
@@ -83,7 +83,7 @@
   'notequals', 'regexp', 'notregexp', 'lessthan', 'lessthaneq', 
   'greaterthan', 'greaterthaneq', 'changedbefore', 'changedafter', 
   'changedfrom', 'changedto', 'changedby', 'notsubstring', 'nowords',
-  'nowordssubstr',
+  'nowordssubstr', 'notmatches',
 ] %]
 <ul class="search_description">
 [% FOREACH desc_item = search_description %]
index db21be681dfebdb1e1087ac892dd569230de07bc..1b79a45948568d63b00338b3f5a8cc96dd43fc23 100644 (file)
@@ -44,6 +44,7 @@
   "changedto",
   "changedby",
   "matches",
+  "notmatches",
 ] %]
 
   <p>