From dc8457ee5c117e48730d737090451b8bdbcbb9de Mon Sep 17 00:00:00 2001 From: Mike Rylander Date: Tue, 3 Sep 2019 16:03:54 -0400 Subject: [PATCH] LP1832897: Avoid query errors related to optional carousel filters Here we make sure that the presence or absence of a shelving location filter value does not lead to a query error. Signed-off-by: Mike Rylander Signed-off-by: Jane Sandberg --- .../perlmods/lib/OpenILS/Application/Storage/Publisher/container.pm | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/container.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/container.pm index a06fd1dcd3..176197a7ab 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/container.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/container.pm @@ -22,6 +22,7 @@ my $new_items_query = q( AND acpl.holdable AND acpl.circulate AND acp.active_date > NOW() - ?::INTERVAL + -- LOC AND acp.location IN (LOC_LIST) AND (EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = acn.record AND vis_attr_vector @@ c_attr.vis_test)) AND (NOT EXISTS (SELECT 1 FROM metabib.record_attr_vector_list WHERE source = acn.record AND vlist @@ metabib.compile_composite_attr(' {"1":[{"_val":"s","_attr":"bib_level"}]}')::query_int)) GROUP BY acn.record @@ -46,6 +47,7 @@ WITH c_attr AS (SELECT c_attrs::query_int AS vis_test FROM asset.patron_default_ AND acpl.circulate AND circ.checkin_time > NOW() - ?::INTERVAL AND circ.checkin_time IS NOT NULL + -- LOC AND acp.location IN (LOC_LIST) AND (EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = acn.record AND vis_attr_vector @@ c_attr.vis_test)) AND (NOT EXISTS (SELECT 1 FROM metabib.record_attr_vector_list WHERE source = acn.record AND vlist @@ metabib.compile_composite_attr(' {"1":[{"_val":"s","_attr":"bib_level"}]}')::query_int)) GROUP BY acn.record @@ -69,6 +71,7 @@ my $top_circs_query = q( AND acpl.holdable AND acpl.circulate AND circ.xact_start > NOW() - ?::INTERVAL + -- LOC AND acp.location IN (LOC_LIST) AND (EXISTS (SELECT 1 FROM asset.copy_vis_attr_cache WHERE record = acn.record AND vis_attr_vector @@ c_attr.vis_test)) AND (NOT EXISTS (SELECT 1 FROM metabib.record_attr_vector_list WHERE source = acn.record AND vlist @@ metabib.compile_composite_attr(' {"1":[{"_val":"s","_attr":"bib_level"}]}')::query_int)) GROUP BY acn.record @@ -86,7 +89,7 @@ my $new_by_loc_query = q( WHERE acn.owning_lib IN (ORG_LIST) AND acp.circ_lib IN (ORG_LIST) AND acp.active_date > NOW() - ?::INTERVAL - AND acp.location IN (LOC_LIST) + -- LOC AND acp.location IN (LOC_LIST) AND acp.holdable AND acp.circulate AND ccs.holdable @@ -144,6 +147,7 @@ sub refresh_container_from_carousel_definition { return 0; } my $loc_placeholders = join(',', map { '?' } @$locs); + $query =~ s/-- LOC //g; $query =~ s/LOC_LIST/$loc_placeholders/g; } else { $locs = []; # we'll ignore any superflous supplied values -- 2.11.0