From: Mike Rylander Date: Tue, 7 Nov 2017 16:09:07 +0000 (-0500) Subject: LP#1723977: Move no-LURIs test to be a peer of no-copies test X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=f0e293517a6e0fd9ee3f43d5a40738cd9dad8998;p=evergreen%2Fpines.git 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 --- 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