From 62080496a50bc343afc464d9855019c8d9b23f11 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 15 Dec 2005 17:01:34 +0000 Subject: [PATCH] reinstating the HAVING clause for all AND-joined searches (the default), but checking for a matching number of UNION terms and output-rows/group. This is not failsafe, but it is close. git-svn-id: svn://svn.open-ils.org/ILS/trunk@2407 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Storage/Publisher/metabib.pm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm index 283c94930a..eb5bd9e740 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm @@ -306,8 +306,11 @@ sub multi_search_full_rec { my $cs_table = config::copy_status->table; my $cl_table = asset::copy_location->table; - my $cj = ''; $cj = 'HAVING COUNT(x.id) > 1' if ($class_join eq 'AND' && @selects > 1); - my $search_table = '(SELECT x.record, sum(x.sum) FROM (('.join(') UNION ALL (', @selects).")) x GROUP BY 1 $cj ORDER BY 2 DESC )"; + my $cj = 'HAVING COUNT(x.id) = ' . scalar(@selects) if ($class_join eq 'AND'); + my $search_table = + '(SELECT x.record, sum(x.sum) FROM (('. + join(') UNION ALL (', @selects). + ")) x GROUP BY 1 $cj ORDER BY 2 DESC )"; my $has_vols = 'AND cn.owning_lib = d.id'; my $has_copies = 'AND cp.call_number = cn.id'; -- 2.43.2