From 409da2ad3a4a675056b37fa7037ff18979b1fa9c Mon Sep 17 00:00:00 2001 From: Byron Jones Date: Wed, 13 Mar 2013 15:09:49 +0800 Subject: Bug 850429: Searching on Due Date Is Empty does not work anymore --- Bugzilla/Search.pm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'Bugzilla') diff --git a/Bugzilla/Search.pm b/Bugzilla/Search.pm index 5fb2352a5..f0cb26357 100644 --- a/Bugzilla/Search.pm +++ b/Bugzilla/Search.pm @@ -1672,7 +1672,7 @@ sub _boolean_charts { 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; + $value = ' ' if $operator && grep { $_ eq $operator } NO_VALUE_OPERATORS; $or_clause->add($field, $operator, $value); } $and_clause->add($or_clause); @@ -1716,7 +1716,7 @@ 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; + $value = ' ' if $operator && grep { $_ eq $operator } NO_VALUE_OPERATORS; my $condition = condition($field, $operator, $value); $condition->negate($params->{"n$id"}); $current_clause->add($condition); @@ -3028,13 +3028,22 @@ 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 = ''"; + $args->{term} = "$full_field IS NULL OR $full_field = " . $self->_empty_value($args->{field}); } sub _isnotempty { my ($self, $args, $join) = @_; my $full_field = $args->{full_field}; - $args->{term} = "$full_field IS NOT NULL AND $full_field != ''"; + $args->{term} = "$full_field IS NOT NULL AND $full_field != " . $self->_empty_value($args->{field}); +} + +sub _empty_value { + my ($self, $field) = @_; + return "''" unless $field =~ /^cf_/; + my $field_obj = $self->_chart_fields->{$field}; + return "0" if $field_obj->type == FIELD_TYPE_BUG_ID; + return Bugzilla->dbh->quote(EMPTY_DATETIME) if $field_obj->type == FIELD_TYPE_DATETIME; + return "''"; } ###################### -- cgit v1.2.3-24-g4f1b