From: Mike Rylander Date: Tue, 16 Dec 2014 01:32:51 +0000 (-0500) Subject: LP#1400376: Don't allow NULL attrs to polute an HSTORE as a key X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=19214534566aee77328d103ba3067880e16164f2;p=evergreen%2Fmasslnc.git LP#1400376: Don't allow NULL attrs to polute an HSTORE as a key That causes the HSTORE to blow up, which is bad for circs that want to succeed. Signed-off-by: Mike Rylander Signed-off-by: Ben Shum --- diff --git a/Open-ILS/src/sql/Pg/030.schema.metabib.sql b/Open-ILS/src/sql/Pg/030.schema.metabib.sql index c03868ed36..58729d8f29 100644 --- a/Open-ILS/src/sql/Pg/030.schema.metabib.sql +++ b/Open-ILS/src/sql/Pg/030.schema.metabib.sql @@ -421,7 +421,10 @@ CREATE VIEW metabib.record_attr_flat AS LEFT JOIN config.coded_value_map c ON ( c.id = ANY( v.vlist ) ); CREATE VIEW metabib.record_attr AS - SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs FROM metabib.record_attr_flat GROUP BY 1; + SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs + FROM metabib.record_attr_flat + WHERE attr IS NOT NULL + GROUP BY 1; -- Back-back-compat view ... we use to live in an HSTORE world CREATE TYPE metabib.rec_desc_type AS ( diff --git a/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql new file mode 100644 index 0000000000..ee7f30572a --- /dev/null +++ b/Open-ILS/src/sql/Pg/upgrade/XXXX.schema.no-null-record_attrs.sql @@ -0,0 +1,10 @@ +BEGIN; + +CREATE OR REPLACE VIEW metabib.record_attr AS + SELECT id, HSTORE( ARRAY_AGG( attr ), ARRAY_AGG( value ) ) AS attrs + FROM metabib.record_attr_flat + WHERE attr IS NOT NULL + GROUP BY 1; + +COMMIT; +