MT#60498 add search by not_null, change null param

* add search by not_null for fields that ends with _id
  and integers, that adds "IS NOT NULL" to the SQL search query
  by the field.
* null and not null values are expected now as $null and $not_null
  to avoid conflicts when user searches by null strings that may
  be a valid case.

Change-Id: I8e8b8c9060e985dfe2b94cbfcca1587f05477fe9
mr13.0
Kirill Solomko 1 year ago
parent 6cb38f0971
commit 524a264850

@ -1105,11 +1105,18 @@ sub apply_query_params {
return $item_rs;
}
my $form = $self->get_form($c);
foreach my $param (reverse _get_sorted_query_params($c,$query_params)) {
my $p = $param;
$p = $p->{param} if ref $p;
my $q = $c->req->query_params->{$p};
$q = undef if $q && !is_int($q) && ($q eq "NULL" or $q eq "null"); # IS NULL translation
my $is_null = $q && !is_int($q) && lc($q) eq '$null';
my $is_not_null = $q && !is_int($q) && lc($q) eq '$not_null';
if ($is_null || $is_not_null) {
$q = undef if $is_null; # IS NULL translation
$q = { '!=' => undef } if $is_not_null; # IS NOT NULL translation
}
next unless ref $param; # skip unknown query parameters
next unless($param->{query} || $param->{query_type} || $param->{new_rs}); # skip dummy query parameters
if (defined $param->{new_rs}) {

Loading…
Cancel
Save