From 35ffea84ffe5628ae7e2b3bbee0241543dd847c5 Mon Sep 17 00:00:00 2001 From: miker Date: Thu, 15 Dec 2005 16:54:27 +0000 Subject: [PATCH] allow single MARC field for searching my removing the HAVING clause when only one field is searched git-svn-id: svn://svn.open-ils.org/ILS/trunk@2406 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../OpenILS/Application/Storage/Publisher/metabib.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 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 14373aab68..283c94930a 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/metabib.pm @@ -289,7 +289,7 @@ sub multi_search_full_rec { } my $where = join(' OR ', @wheres); - push @selects, "SELECT record, sum($rank) FROM $search_table WHERE $where GROUP BY 1 ORDER BY 2 DESC"; + push @selects, "SELECT id, record, $rank as sum FROM $search_table WHERE $where"; } @@ -306,8 +306,8 @@ 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.record) > 1' if ($class_join eq 'AND'); - my $search_table = '(SELECT x.record, sum(x.sum) FROM (('.join(') UNION ALL (', @selects).")) x GROUP BY 1 $cj )"; + 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 $has_vols = 'AND cn.owning_lib = d.id'; my $has_copies = 'AND cp.call_number = cn.id'; -- 2.43.2