]> 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:14:14 +0000 (14:14 -0700)
committerMax Kanat-Alexander <mkanat@bugzilla.org>
Mon, 29 Mar 2010 21:14:14 +0000 (14:14 -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 56f1a5c28cf4e24113d93c24a7c816fc0991d8c9..a0d9718ecf8e928d1b735696edbfb4a569c64315 100644 (file)
@@ -615,7 +615,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|lessthaneq|greaterthan|greaterthaneq|equals|notequals),(?:-|\\+)?(?:\\d+)(?:[dDwWmMyY])\$" => \&_timestamp_compare,
         "^commenter,(?:equals|anyexact),(%\\w+%)" => \&_commenter_exact,
@@ -660,6 +660,7 @@ sub init {
         ",lessthan" => \&_lessthan,
         ",lessthaneq" => \&_lessthaneq,
         ",matches" => sub { ThrowUserError("search_content_without_matches"); },
+        ",notmatches" => sub { ThrowUserError("search_content_without_matches"); },
         ",greaterthan" => \&_greaterthan,
         ",greaterthaneq" => \&_greaterthaneq,
         ",anyexact" => \&_anyexact,
@@ -1420,8 +1421,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
@@ -1448,19 +1449,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 c71fab85b8d567702e370a210ea6690c0632b082..7839c4fd57d369e4c7748511fe55903f750666d2 100644 (file)
@@ -524,19 +524,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 7d2fa3533e096f8d8512fb4eb1934ec671b7af93..1819a4f967cbda5040bb56138b61e08b59413dce 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 6c6b93a9ff7f3f6177fafa993a167ac406aed7b4..bbe1aba7b48a0fab1aa6dc2d7791cca3d102919b 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 4431a52f353f88c5321e00cabb6808b3762cbd61..4743d260d158eb3ae198b8b0994d95529aef9e02 100644 (file)
@@ -85,7 +85,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 a58efc9a9d4d7ebcbc9eabc5ea814ec79924d9ed..a8d018556230b01bb0503d6e3336ef47564af5be 100644 (file)
@@ -46,6 +46,7 @@
   "changedto",
   "changedby",
   "matches",
+  "notmatches",
 ] %]
 
   <h3 id="chart">