add __isnotnull as acq search field modifier
authorGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Apr 2020 20:42:16 +0000 (16:42 -0400)
committerGalen Charlton <gmc@equinoxinitiative.org>
Mon, 27 Apr 2020 20:42:16 +0000 (16:42 -0400)
Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Acq/Search.pm

index cd7e852..35965fe 100644 (file)
@@ -79,7 +79,7 @@ sub prepare_acqlia_search_and {
         };
 
         # castdate not supported for acqlia fields: they're all type text
-        my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt) = breakdown_term($unit);
+        my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt, $notnull) = breakdown_term($unit);
         my $point = $subquery->{"where"}->{"-and"};
         my $term_clause;
 
@@ -101,6 +101,8 @@ sub prepare_acqlia_search_and {
             push @$point, {"attr_value" => {"<" => $v}};
         } elsif ($between and could_be_range($v)) {
             push @$point, {"attr_value" => {"between" => $v}};
+        } elsif ($notnull) {
+            push @$point, {"attr_value" => {"!=" => undef}};
         } elsif (check_1d_max($v)) {
             push @$point, {"attr_value" => $v};
         } else {
@@ -208,6 +210,7 @@ sub breakdown_term {
         $term->{"__age"} ? 1 : 0,
         $term->{"__gt"} ? 1 : 0,
         $term->{"__lt"} ? 1 : 0,
+        $term->{"__isnotnull"} ? 1 : 0,
     );
 }
 
@@ -384,7 +387,7 @@ sub prepare_terms {
         $outer_clause->{$conj} = [] unless $outer_clause->{$conj};
         foreach my $unit (@{$terms->{$class}}) {
             my $special_clause;
-            my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt) =
+            my ($k, $v, $fuzzy, $between, $not, $starts, $ends, $castdate, $gte, $lte, $age, $gt, $lt, $notnull) =
                 breakdown_term($unit);
 
             my $term_clause;
@@ -414,6 +417,8 @@ sub prepare_terms {
                 } else {
                     $term_clause = {$k => {between => $v}};
                 }
+            } elsif ($notnull) {
+                $term_clause = {$k => {"!=" => undef}};
             } elsif (check_1d_max($v)) {
                 if ($castdate) {
                     $v = castdate($v, $gte, $lte, 0, $gt, $lt);