JBAS-2285 find auth rec for browse entry fixes
authorBill Erickson <berickxx@gmail.com>
Thu, 23 May 2019 15:01:19 +0000 (15:01 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 23 May 2019 15:06:18 +0000 (15:06 +0000)
Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/stock-browse-schema.sql

index 0548f9a..ff36e84 100644 (file)
@@ -106,7 +106,11 @@ $FUNK$
     JOIN config.metabib_field cmf ON (cmf.id = map.metabib_field)
     WHERE   mbe.id = browse_entry
         AND acsaf.main_entry IS NULL
-        AND cmf.field_class = search_class;
+        AND NOT are.deleted
+        AND cmf.field_class = search_class
+    -- assume the largest record is the best as a tie breaker.
+    ORDER BY LENGTH(are.marc) DESC
+    LIMIT 1;
 $FUNK$ LANGUAGE SQL STABLE;
 
 -- DROP LOCAL FUNCS TO ENSURE NONE STICK AROUND w/ DIFFERENT SIGNATURES