From f0e293517a6e0fd9ee3f43d5a40738cd9dad8998 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 --- .../lib/OpenILS/Application/Storage/Driver/Pg/QueryParser.pm | 6 ++++++ 1 file changed, 6 insertions(+) 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 28624f0b44..de586c4c2a 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 @@ -1013,6 +1013,12 @@ sub toSQL { $$flat_plan{with} .= "c_attr AS (SELECT (ARRAY_TO_STRING(ARRAY[$vis_test],'&'))::query_int AS vis_test FROM asset.patron_default_visibility_mask() x)"; $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) " . + "AND (bre.vis_attr_vector IS NULL OR NOT ( int4range(0,268435455,'[]') @> ANY(bre.vis_attr_vector) ))". + "))"; + } } if ($self->find_modifier('staff')) { # staff search -- 2.11.0