Commit dddef33e authored by Max Kanat-Alexander's avatar Max Kanat-Alexander

Bug 637426: Fix every boolean chart operator type for the bug_group search

field in Search.pm. (This also makes OR searches work against the bug_group field.) r=mkanat, a=mkanat
parent 86d6af69
...@@ -277,9 +277,7 @@ use constant OPERATOR_FIELD_OVERRIDE => { ...@@ -277,9 +277,7 @@ use constant OPERATOR_FIELD_OVERRIDE => {
blocked => { blocked => {
_non_changed => \&_blocked_nonchanged, _non_changed => \&_blocked_nonchanged,
}, },
bug_group => { bug_group => MULTI_SELECT_OVERRIDE,
_non_changed => \&_bug_group_nonchanged,
},
classification => { classification => {
_non_changed => \&_classification_nonchanged, _non_changed => \&_classification_nonchanged,
}, },
...@@ -2364,30 +2362,6 @@ sub _percentage_complete { ...@@ -2364,30 +2362,6 @@ sub _percentage_complete {
$self->_add_extra_column('actual_time'); $self->_add_extra_column('actual_time');
} }
sub _bug_group_nonchanged {
my ($self, $args) = @_;
my ($chart_id, $joins, $field) = @$args{qw(chart_id joins field)};
my $map_table = "bug_group_map_$chart_id";
push(@$joins, { table => 'bug_group_map', as => $map_table });
my $groups_table = "groups_$chart_id";
my $full_field = "$groups_table.name";
$args->{full_field} = $full_field;
$self->_do_operator_function($args);
my $term = $args->{term};
my $groups_join = {
table => 'groups',
as => $groups_table,
from => "$map_table.group_id",
to => 'id',
extra => [$term],
};
push(@$joins, $groups_join);
$args->{term} = "$full_field IS NOT NULL";
}
sub _attach_data_thedata { sub _attach_data_thedata {
my ($self, $args) = @_; my ($self, $args) = @_;
my ($chart_id, $joins) = @$args{qw(chart_id joins)}; my ($chart_id, $joins) = @$args{qw(chart_id joins)};
...@@ -2688,6 +2662,11 @@ sub _multiselect_table { ...@@ -2688,6 +2662,11 @@ sub _multiselect_table {
return "bug_tag INNER JOIN tags ON bug_tag.tag_id = tags.id" return "bug_tag INNER JOIN tags ON bug_tag.tag_id = tags.id"
. " AND user_id = " . $self->_user->id; . " AND user_id = " . $self->_user->id;
} }
elsif ($field eq 'bug_group') {
$args->{full_field} = 'groups.name';
return "bug_group_map INNER JOIN groups
ON bug_group_map.group_id = groups.id";
}
my $table = "bug_$field"; my $table = "bug_$field";
$args->{full_field} = "bug_$field.value"; $args->{full_field} = "bug_$field.value";
return $table; return $table;
......
...@@ -198,12 +198,6 @@ use constant SUBSTR_NO_FIELD_ADD => FIELD_TYPE_DATETIME, qw( ...@@ -198,12 +198,6 @@ use constant SUBSTR_NO_FIELD_ADD => FIELD_TYPE_DATETIME, qw(
# the bug you listed. It doesn't find bugs that fully lack values for # the bug you listed. It doesn't find bugs that fully lack values for
# the fields, as it should. # the fields, as it should.
# #
# cc "not" matches if any CC'ed user matches, and it fails to match
# if there are no CCs on the bug.
#
# bug_group notequals doesn't find bugs that fully lack groups,
# and matches if there is one group that isn't equal.
#
# bug_file_loc can be NULL, so it gets missed by the normal # bug_file_loc can be NULL, so it gets missed by the normal
# notequals search. # notequals search.
# #
...@@ -228,7 +222,6 @@ use constant NEGATIVE_BROKEN => ( ...@@ -228,7 +222,6 @@ use constant NEGATIVE_BROKEN => (
'attachments.mimetype' => { contains => [5] }, 'attachments.mimetype' => { contains => [5] },
blocked => { contains => [3,4,5] }, blocked => { contains => [3,4,5] },
bug_file_loc => { contains => [5] }, bug_file_loc => { contains => [5] },
bug_group => { contains => [1,5] },
deadline => { contains => [5] }, deadline => { contains => [5] },
dependson => { contains => [2,4,5] }, dependson => { contains => [2,4,5] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
...@@ -245,13 +238,12 @@ use constant NEGATIVE_BROKEN => ( ...@@ -245,13 +238,12 @@ use constant NEGATIVE_BROKEN => (
# As with other fields, longdescs greaterthan matches if any comment # As with other fields, longdescs greaterthan matches if any comment
# matches (which might be OK). # matches (which might be OK).
# #
# Same for keywords, bug_group, and cc. Logically, all of these might # Same for keywords, and cc. Logically, all of these might
# be OK, but it makes the operation not the logical reverse of # be OK, but it makes the operation not the logical reverse of
# lessthaneq. What we're really saying here by marking these broken # lessthaneq. What we're really saying here by marking these broken
# is that there ought to be some way of searching "all ccs" vs "any cc" # is that there ought to be some way of searching "all ccs" vs "any cc"
# (and same for the other fields). # (and same for the other fields).
use constant GREATERTHAN_BROKEN => ( use constant GREATERTHAN_BROKEN => (
bug_group => { contains => [1] },
cc => { contains => [1] }, cc => { contains => [1] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
); );
...@@ -260,9 +252,8 @@ use constant GREATERTHAN_BROKEN => ( ...@@ -260,9 +252,8 @@ use constant GREATERTHAN_BROKEN => (
# #
# allwordssubstr on longdescs fields matches against a single comment, # allwordssubstr on longdescs fields matches against a single comment,
# instead of matching against all comments on a bug. Same is true # instead of matching against all comments on a bug. Same is true
# for cc and bug_group. # for cc.
use constant ALLWORDS_BROKEN => ( use constant ALLWORDS_BROKEN => (
bug_group => { contains => [1] },
cc => { contains => [1] }, cc => { contains => [1] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
); );
...@@ -270,15 +261,14 @@ use constant ALLWORDS_BROKEN => ( ...@@ -270,15 +261,14 @@ use constant ALLWORDS_BROKEN => (
# nowords and nowordssubstr have these broken tests in common. # nowords and nowordssubstr have these broken tests in common.
# #
# flagtypes.name doesn't match bugs without flags. # flagtypes.name doesn't match bugs without flags.
# longdescs.isprivate, and bug_group actually work properly in # longdescs.isprivate actually works properly in
# terms of excluding bug 1 (since we exclude all values in the search, # terms of excluding bug 1 (since we exclude all values in the search,
# on our test), but still fail at including bug 5. # on our test), but still fails at including bug 5.
# The longdesc* fields, coincidentally, work completely # The longdesc* fields, coincidentally, work completely
# correctly, possibly because there's only one comment on bug 5. # correctly, possibly because there's only one comment on bug 5.
use constant NOWORDS_BROKEN => ( use constant NOWORDS_BROKEN => (
NEGATIVE_BROKEN, NEGATIVE_BROKEN,
'flagtypes.name' => { contains => [5] }, 'flagtypes.name' => { contains => [5] },
bug_group => { contains => [5] },
longdesc => {}, longdesc => {},
'longdescs.isprivate' => {}, 'longdescs.isprivate' => {},
); );
...@@ -496,10 +486,9 @@ use constant CHANGED_FROM_TO_BROKEN_NOT => ( ...@@ -496,10 +486,9 @@ use constant CHANGED_FROM_TO_BROKEN_NOT => (
# Common broken tests for the "not" or "no" operators. # Common broken tests for the "not" or "no" operators.
use constant NEGATIVE_BROKEN_NOT => ( use constant NEGATIVE_BROKEN_NOT => (
"blocked" => { contains => [3, 4, 5] }, "blocked" => { contains => [3, 4, 5] },
"bug_group" => { contains => [5] }, "dependson" => { contains => [2, 4, 5] },
"dependson" => { contains => [2, 4, 5] }, "flagtypes.name" => { contains => [1 .. 5] },
"flagtypes.name" => { contains => [1 .. 5] },
); );
# These are field/operator combinations that are broken when run under NOT(). # These are field/operator combinations that are broken when run under NOT().
...@@ -507,13 +496,11 @@ use constant BROKEN_NOT => { ...@@ -507,13 +496,11 @@ use constant BROKEN_NOT => {
allwords => { allwords => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
cc => { contains => [1] }, cc => { contains => [1] },
bug_group => { contains => [1] },
"flagtypes.name" => { contains => [1,5] }, "flagtypes.name" => { contains => [1,5] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
}, },
'allwords-<1> <2>' => { 'allwords-<1> <2>' => {
'attach_data.thedata' => { contains => [5] }, 'attach_data.thedata' => { contains => [5] },
bug_group => { },
cc => { }, cc => { },
'flagtypes.name' => { contains => [5] }, 'flagtypes.name' => { contains => [5] },
'longdesc' => { }, 'longdesc' => { },
...@@ -521,12 +508,10 @@ use constant BROKEN_NOT => { ...@@ -521,12 +508,10 @@ use constant BROKEN_NOT => {
}, },
allwordssubstr => { allwordssubstr => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
bug_group => { contains => [1] },
cc => { contains => [1] }, cc => { contains => [1] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
}, },
'allwordssubstr-<1>,<2>' => { 'allwordssubstr-<1>,<2>' => {
bug_group => { },
cc => { }, cc => { },
"longdesc" => { }, "longdesc" => { },
"longdescs.isprivate" => { }, "longdescs.isprivate" => { },
...@@ -536,9 +521,6 @@ use constant BROKEN_NOT => { ...@@ -536,9 +521,6 @@ use constant BROKEN_NOT => {
"flagtypes.name" => { contains => [1, 2, 5] }, "flagtypes.name" => { contains => [1, 2, 5] },
"longdesc" => { contains => [1, 2] }, "longdesc" => { contains => [1, 2] },
}, },
'anyexact-<1>, <2>' => {
bug_group => { contains => [1] },
},
anywords => { anywords => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
}, },
...@@ -550,11 +532,9 @@ use constant BROKEN_NOT => { ...@@ -550,11 +532,9 @@ use constant BROKEN_NOT => {
}, },
casesubstring => { casesubstring => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
bug_group => { contains => [1] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
}, },
'casesubstring-<1>-lc' => { 'casesubstring-<1>-lc' => {
bug_group => { },
longdesc => { }, longdesc => { },
}, },
changedafter => { changedafter => {
...@@ -593,7 +573,6 @@ use constant BROKEN_NOT => { ...@@ -593,7 +573,6 @@ use constant BROKEN_NOT => {
}, },
equals => { equals => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
bug_group => { contains => [1] },
"flagtypes.name" => { contains => [1, 5] }, "flagtypes.name" => { contains => [1, 5] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
}, },
...@@ -611,12 +590,8 @@ use constant BROKEN_NOT => { ...@@ -611,12 +590,8 @@ use constant BROKEN_NOT => {
longdesc => { contains => [1] }, longdesc => { contains => [1] },
'longdescs.isprivate' => { }, 'longdescs.isprivate' => { },
}, },
'lessthan-2' => {
bug_group => { contains => [1] },
},
lessthaneq => { lessthaneq => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
bug_group => { contains => [1] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
'longdescs.isprivate' => { }, 'longdescs.isprivate' => { },
}, },
...@@ -634,7 +609,6 @@ use constant BROKEN_NOT => { ...@@ -634,7 +609,6 @@ use constant BROKEN_NOT => {
}, },
regexp => { regexp => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
bug_group => { contains => [1] },
"flagtypes.name" => { contains => [1,5] }, "flagtypes.name" => { contains => [1,5] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
}, },
...@@ -643,7 +617,6 @@ use constant BROKEN_NOT => { ...@@ -643,7 +617,6 @@ use constant BROKEN_NOT => {
}, },
substring => { substring => {
COMMON_BROKEN_NOT, COMMON_BROKEN_NOT,
bug_group => { contains => [1] },
longdesc => { contains => [1] }, longdesc => { contains => [1] },
}, },
}; };
...@@ -697,6 +670,7 @@ use constant GREATERTHAN_OVERRIDE => ( ...@@ -697,6 +670,7 @@ use constant GREATERTHAN_OVERRIDE => (
classification => { contains => [2,3,4,5] }, classification => { contains => [2,3,4,5] },
assigned_to => { contains => [2,3,4,5] }, assigned_to => { contains => [2,3,4,5] },
bug_id => { contains => [2,3,4,5] }, bug_id => { contains => [2,3,4,5] },
bug_group => { contains => [1,2,3,4] },
bug_severity => { contains => [2,3,4,5] }, bug_severity => { contains => [2,3,4,5] },
bug_status => { contains => [2,3,4,5] }, bug_status => { contains => [2,3,4,5] },
component => { contains => [2,3,4,5] }, component => { contains => [2,3,4,5] },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment