JBAS-2284 Identifier (call number) browse respects '.' chars
authorBill Erickson <berickxx@gmail.com>
Thu, 16 May 2019 18:53:38 +0000 (18:53 +0000)
committerBill Erickson <berickxx@gmail.com>
Thu, 16 May 2019 18:53:41 +0000 (18:53 +0000)
When performing an identifier browse, avoid stripping '.' characters
from the sort value when locating the browse pivot.

Signed-off-by: Bill Erickson <berickxx@gmail.com>
KCLS/sql/schema/deploy/3.2-additions.sql

index d7e25e5..dfd7008 100644 (file)
@@ -3,6 +3,33 @@
 
 BEGIN;
 
+CREATE OR REPLACE FUNCTION metabib.browse_pivot(
+    search_field INT[], browse_term TEXT
+) RETURNS BIGINT AS $p$
+-- handles 'search_field' conflict.  using this means I don't
+-- have to drop/recreate the function and those that rely on it 
+-- just to change the 'search_field' param name.
+#variable_conflict use_variable
+DECLARE
+    sort_value TEXT;
+BEGIN
+    SELECT INTO sort_value
+        CASE WHEN cmf.field_class = 'identifier' THEN 
+            public.naco_normalize_keep_decimal($2, '')
+        ELSE 
+            public.naco_normalize($2)
+        END
+    FROM config.metabib_field cmf
+    WHERE cmf.id = search_field[1];
+
+    RETURN id FROM metabib.browse_entry
+    WHERE metabib_fields_cache && $1
+    AND combo_sort_value >= sort_value
+    ORDER BY combo_sort_value LIMIT 1;
+END;
+$p$ LANGUAGE PLPGSQL STABLE;
+
+
 DO $INSERT$
 BEGIN
     IF evergreen.insert_on_deploy() THEN