improve metarecord constituent record test
authormiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 7 Mar 2008 02:58:33 +0000 (02:58 +0000)
committermiker <miker@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Fri, 7 Mar 2008 02:58:33 +0000 (02:58 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/trunk@8891 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/src/sql/Pg/300.schema.staged_search.sql

index 655921b..17746c6 100644 (file)
@@ -396,7 +396,12 @@ BEGIN
             current_res.id = core_result.id;
             current_res.rel = core_result.rel;
 
-            IF array_upper(core_result.records, 1) = 1 THEN
+            tmp_int := 1;
+            IF metarecord THEN
+                SELECT COUNT(DISTINCT s.source) INTO tmp_int FROM metabib.metarecord_source_map s WHERE s.metarecord = core_result.id;
+            END IF;
+
+            IF tmp_int = 1 THEN
                 current_res.record = core_result.records[1];
             ELSE
                 current_res.record = NULL;
@@ -458,7 +463,12 @@ BEGIN
         current_res.id = core_result.id;
         current_res.rel = core_result.rel;
 
-        IF array_upper(core_result.records, 1) = 1 THEN
+        tmp_int := 1;
+        IF metarecord THEN
+            SELECT COUNT(DISTINCT s.source) INTO tmp_int FROM metabib.metarecord_source_map s WHERE s.metarecord = core_result.id;
+        END IF;
+
+        IF tmp_int = 1 THEN
             current_res.record = core_result.records[1];
         ELSE
             current_res.record = NULL;