Need to protect against null values for sorters
authorMike Rylander <miker@esilibrary.com>
Tue, 21 Jan 2014 18:29:43 +0000 (13:29 -0500)
committerMike Rylander <mrylander@gmail.com>
Wed, 29 Jan 2014 18:24:50 +0000 (13:24 -0500)
Signed-off-by: Mike Rylander <miker@esilibrary.com>
Open-ILS/src/sql/Pg/030.schema.metabib.sql
Open-ILS/src/sql/Pg/upgrade/YYYY.schema.CRA.sql

index ad9943a..2ab787d 100644 (file)
@@ -1539,7 +1539,7 @@ BEGIN
             attr_vector := attr_vector || attr_vector_tmp;
         END IF;
 
-        IF attr_def.sorter THEN
+        IF attr_def.sorter AND norm_attr_value[1] IS NOT NULL THEN
             DELETE FROM metabib.record_sorter WHERE source = rid AND attr = attr_def.name;
             INSERT INTO metabib.record_sorter (source, attr, value) VALUES (rid, attr_def.name, norm_attr_value[1]);
         END IF;
index cdc3e78..9fae927 100644 (file)
@@ -224,7 +224,7 @@ BEGIN
             attr_vector := attr_vector || attr_vector_tmp;
         END IF;
 
-        IF attr_def.sorter THEN
+        IF attr_def.sorter AND norm_attr_value[1] IS NOT NULL THEN
             DELETE FROM metabib.record_sorter WHERE source = rid AND attr = attr_def.name;
             INSERT INTO metabib.record_sorter (source, attr, value) VALUES (rid, attr_def.name, norm_attr_value[1]);
         END IF;