From 5a187c8148653e6b9d0fc32f10a008fa4069a603 Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 7 Nov 2017 11:09:07 -0500 Subject: [PATCH] LP#1723977: Move no-LURIs test to be a peer of no-copies test The correct place to test the no-LURIs condition is as a peer to the no-copies test, when searching in staff mode. We therefore move that test with this commit. In addition, 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 Signed-off-by: Jason Boyer Signed-off-by: Galen Charlton --- .../lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 8 ++++---- Open-ILS/src/sql/Pg/300.schema.staged_search.sql | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm index f643d5f228..1fb0c9f8f2 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm @@ -1014,7 +1014,10 @@ sub toSQL { $final_c_attr_test = 'EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source AND vis_attr_vector @@ c_attr.vis_test)'; 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))'; + $final_c_attr_test = '(' . $final_c_attr_test . " OR (" . + "NOT EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = m.source) " . + "AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))". + "))"; } } @@ -1051,9 +1054,6 @@ sub toSQL { # These are magic numbers... see: search.calculate_visibility_attribute() UDF $final_b_attr_test = '(b_attr.vis_test IS NULL OR bre.vis_attr_vector @@ b_attr.vis_test)'; - if (!$pb_vis_test) { # staff search - $final_b_attr_test .= " OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) )"; - } } if ($final_c_attr_test or $final_b_attr_test) { # something... diff --git a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql index 3349a45a1a..8dabef943f 100644 --- a/Open-ILS/src/sql/Pg/300.schema.staged_search.sql +++ b/Open-ILS/src/sql/Pg/300.schema.staged_search.sql @@ -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; -- 2.11.0