LP#1723977: Test for NULLness of bib attr vector user/miker/lp-1723977-staff-visibility-test
authorMike Rylander <miker@esilibrary.com>
Tue, 7 Nov 2017 18:59:21 +0000 (13:59 -0500)
committerMike Rylander <miker@esilibrary.com>
Tue, 7 Nov 2017 18:59:21 +0000 (13:59 -0500)
The bib attribute vector may be null, in the case of a record with no bib source
or LURI.  When testing emptiness we need to ask if the field IS NULL rather than
just testing its contents.

Signed-off-by: Mike Rylander <miker@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm
Open-ILS/src/sql/Pg/300.schema.staged_search.sql

index db9bbef..1fb0c9f 100644 (file)
@@ -1016,7 +1016,7 @@ sub toSQL {
         if (!$pc_vis_test) { # staff search
             $final_c_attr_test = '(' . $final_c_attr_test . " OR (" .
                     "NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source) " .
-                    "AND NOT ( int3range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) )".
+                    "AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))".
                 "))";
         }
     }
index 3349a45..8dabef9 100644 (file)
@@ -593,7 +593,7 @@ BEGIN
             RETURN NEW;
         ELSIF TG_OP = 'DELETE' THEN
             DELETE FROM asset.copy_vis_attr_cache
-              WHERE record = NEW.peer_record AND target_copy = NEW.target_copy;
+              WHERE record = OLD.peer_record AND target_copy = OLD.target_copy;
 
             RETURN OLD;
         END IF;