Commit a7859e10 authored by Byron Jones's avatar Byron Jones

Bug 828344: "contains all of the words" no longer looks for all words within the…

Bug 828344: "contains all of the words" no longer looks for all words within the same comment or flag r=LpSolit, a=LpSolit
parent 2baddffa
...@@ -1817,6 +1817,7 @@ sub _handle_chart { ...@@ -1817,6 +1817,7 @@ sub _handle_chart {
joins => [], joins => [],
bugs_table => 'bugs', bugs_table => 'bugs',
table_suffix => '', table_suffix => '',
condition => $condition,
); );
$clause->update_search_args(\%search_args); $clause->update_search_args(\%search_args);
...@@ -2725,59 +2726,50 @@ sub _multiselect_multiple { ...@@ -2725,59 +2726,50 @@ sub _multiselect_multiple {
sub _flagtypes_nonchanged { sub _flagtypes_nonchanged {
my ($self, $args) = @_; my ($self, $args) = @_;
my ($chart_id, $operator, $value, $joins, $bugs_table) = my ($chart_id, $operator, $value, $joins, $bugs_table, $condition) =
@$args{qw(chart_id operator value joins bugs_table)}; @$args{qw(chart_id operator value joins bugs_table condition)};
my $dbh = Bugzilla->dbh; my $dbh = Bugzilla->dbh;
my $join;
# join to the attachments table
my $attach_table = "attachments_$chart_id";
$join = {
table => 'attachments',
as => $attach_table,
from => "$bugs_table.bug_id",
to => "bug_id",
extra => [ ($self->_user->is_insider ? '' : "$attach_table.isprivate = 0") ],
};
push(@$joins, $join);
# join to the flags table # For 'not' operators, we need to negate the whole term.
my $flags_table = "flags_$chart_id"; # If you search for "Flags" (does not contain) "approval+" we actually want
$join = { # to return *bugs* that don't contain an approval+ flag. Without rewriting
table => 'flags', # the negation we'll search for *flags* which don't contain approval+.
as => $flags_table, if ($operator =~ s/^not//) {
from => "$bugs_table.bug_id", $args->{operator} = $operator;
to => "bug_id", $condition->operator($operator);
extra => [ "($flags_table.attach_id = $attach_table.attach_id " . $condition->negate(1);
" OR $flags_table.attach_id IS NULL)" ], }
};
push(@$joins, $join);
# join to the flagtypes table
my $flagtypes_table = "flagtypes_$chart_id";
$join = {
table => 'flagtypes',
as => $flagtypes_table,
from => "$flags_table.type_id",
to => "id",
};
push(@$joins, $join);
# join to the profiles table for the requestee my $subselect_args = {
my $flag_profile_table = "flag_profiles_$chart_id"; chart_id => $chart_id,
$join = { sequence => $chart_id,
table => 'profiles', field => 'flagtypes.name',
as => $flag_profile_table, full_field => $dbh->sql_string_concat("flagtypes_$chart_id.name", "flags_$chart_id.status"),
from => "$flags_table.requestee_id", operator => $operator,
to => "userid", value => $value,
all_values => $value,
quoted => $dbh->quote($value),
joins => [],
bugs_table => "bugs_$chart_id",
}; };
push(@$joins, $join); $self->_do_operator_function($subselect_args);
my $subselect_term = $subselect_args->{term};
$args->{full_field} = $dbh->sql_string_concat("$flagtypes_table.name",
"$flags_table.status", # don't call build_subselect as this must run as a true sub-select
"COALESCE($flag_profile_table.login_name, '')"); $args->{term} = "EXISTS (
SELECT 1
$self->_do_operator_function($args); FROM $bugs_table bugs_$chart_id
LEFT JOIN attachments AS attachments_$chart_id
ON bugs_$chart_id.bug_id = attachments_$chart_id.bug_id
LEFT JOIN flags AS flags_$chart_id
ON bugs_$chart_id.bug_id = flags_$chart_id.bug_id
AND (flags_$chart_id.attach_id = attachments_$chart_id.attach_id
OR flags_$chart_id.attach_id IS NULL)
LEFT JOIN flagtypes AS flagtypes_$chart_id
ON flags_$chart_id.type_id = flagtypes_$chart_id.id
WHERE bugs_$chart_id.bug_id = $bugs_table.bug_id
AND $subselect_term
)";
} }
sub _multiselect_nonchanged { sub _multiselect_nonchanged {
......
...@@ -21,9 +21,16 @@ sub new { ...@@ -21,9 +21,16 @@ sub new {
} }
sub field { return $_[0]->{field} } sub field { return $_[0]->{field} }
sub operator { return $_[0]->{operator} }
sub value { return $_[0]->{value} } sub value { return $_[0]->{value} }
sub operator {
my ($self, $value) = @_;
if (@_ == 2) {
$self->{operator} = $value;
}
return $self->{operator};
}
sub fov { sub fov {
my ($self) = @_; my ($self) = @_;
return ($self->field, $self->operator, $self->value); return ($self->field, $self->operator, $self->value);
......
...@@ -364,8 +364,15 @@ sub _handle_field_names { ...@@ -364,8 +364,15 @@ sub _handle_field_names {
my ($or_operand, $negate, $unknownFields, $ambiguous_fields) = @_; my ($or_operand, $negate, $unknownFields, $ambiguous_fields) = @_;
# Flag and requestee shortcut # Flag and requestee shortcut
if ($or_operand =~ /^(?:flag:)?([^\?]+\?[^\?]*)$/) { if ($or_operand =~ /^(?:flag:)?([^\?]+\?)([^\?]*)$/) {
addChart('flagtypes.name', 'substring', $1, $negate); my ($flagtype, $requestee) = ($1, $2);
addChart('flagtypes.name', 'substring', $flagtype, $negate);
if ($requestee) {
# AND
$chart++;
$and = $or = 0;
addChart('requestees.login_name', 'substring', $requestee, $negate);
}
return 1; return 1;
} }
......
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