From 2591846d72d5c1a3d577e9af80fc5fdb6026602d Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Tue, 26 Feb 2013 13:57:28 +0800 Subject: restore isempty/isnotempty operators to bmo/4.2 --- Bugzilla/Search.pm | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'Bugzilla/Search.pm') diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index d2148a9c2..0cf618a4c 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -183,6 +183,8 @@ use constant OPERATORS => { changedfrom => \&_changedfrom_changedto, changedto => \&_changedfrom_changedto, changedby => \&_changedby, + isempty => \&_isempty, + isnotempty => \&_isnotempty, }; # Some operators are really just standard SQL operators, and are @@ -224,6 +226,12 @@ use constant NON_NUMERIC_OPERATORS => qw( notregexp ); +# These operators ignore the entered value +use constant NO_VALUE_OPERATORS => qw( + isempty + isnotempty +); + use constant MULTI_SELECT_OVERRIDE => { notequals => \&_multiselect_negative, notregexp => \&_multiselect_negative, @@ -1597,6 +1605,8 @@ sub _boolean_charts { my $field = $params->{"field$identifier"}; my $operator = $params->{"type$identifier"}; my $value = $params->{"value$identifier"}; + # no-value operators ignore the value, however a value needs to be set + $value = ' ' if grep { $_ eq $operator } NO_VALUE_OPERATORS; $or_clause->add($field, $operator, $value); } $and_clause->add($or_clause); @@ -1639,6 +1649,8 @@ sub _custom_search { my $operator = $params->{"o$id"}; my $value = $params->{"v$id"}; + # no-value operators ignore the value, however a value needs to be set + $value = ' ' if grep { $_ eq $operator } NO_VALUE_OPERATORS; my $condition = condition($field, $operator, $value); $condition->negate($params->{"n$id"}); $current_clause->add($condition); @@ -2947,6 +2959,18 @@ sub _changed_security_check { } } +sub _isempty { + my ($self, $args, $join) = @_; + my $full_field = $args->{full_field}; + $args->{term} = "$full_field IS NULL OR $full_field = ''"; +} + +sub _isnotempty { + my ($self, $args, $join) = @_; + my $full_field = $args->{full_field}; + $args->{term} = "$full_field IS NOT NULL AND $full_field != ''"; +} + ###################### # Public Subroutines # ###################### -- cgit v1.2.3-24-g4f1b