LP#1152753: fix fake FK trigger on vandelay.import_item
authorGalen Charlton <gmc@equinoxinitiative.org>
Fri, 1 Sep 2017 21:22:42 +0000 (17:22 -0400)
committerMike Rylander <mrylander@gmail.com>
Fri, 1 Sep 2017 21:17:47 +0000 (17:17 -0400)
Fixes a regression caught by live_t/0824.item_import_defaults.pg

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/src/sql/Pg/800.fkeys.sql

index 8ae7d26..1ee6ead 100644 (file)
@@ -110,6 +110,9 @@ ALTER TABLE serial.unit ADD CONSTRAINT serial_unit_editor_fkey FOREIGN KEY (edit
 
 CREATE OR REPLACE FUNCTION evergreen.vandelay_import_item_imported_as_inh_fkey() RETURNS TRIGGER AS $f$
 BEGIN
+        IF NEW.imported_as IS NULL THEN
+                RETURN NEW;
+        END IF;
         PERFORM 1 FROM asset.copy WHERE id = NEW.imported_as;
         IF NOT FOUND THEN
                 RAISE foreign_key_violation USING MESSAGE = FORMAT(