From f5445b332ac73379208f75b76ba95c1b722aec26 Mon Sep 17 00:00:00 2001 From: Stevan Earl Date: Thu, 13 Aug 2026 10:35:18 -0700 Subject: [PATCH] Use ARRIVALS.Swelling in trigger checks --- db/schemas/lib/triggers/create/arrivals.m4 | 56 +++++++++++----------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/db/schemas/lib/triggers/create/arrivals.m4 b/db/schemas/lib/triggers/create/arrivals.m4 index a9290d6..b6f2caa 100644 --- a/db/schemas/lib/triggers/create/arrivals.m4 +++ b/db/schemas/lib/triggers/create/arrivals.m4 @@ -119,8 +119,8 @@ CREATE OR REPLACE FUNCTION arrivals_before_func () || ' EVENTS.Behavior value of (sdb_arrival)' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Value (DataSource) = (' || NEW.datasource || '): Key (ROLES.PID) = (' @@ -164,8 +164,8 @@ CREATE OR REPLACE FUNCTION arrivals_before_func () , DETAIL = 'Arrivals must have a related ROLES row' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Value (DataSource) = (' || NEW.datasource || '): Key (ROLES.PID) = (' @@ -280,8 +280,8 @@ CREATE OR REPLACE FUNCTION arrivals_before_func () || NEW.neststart || '): Value (NestEnd) = (' || NEW.nestend - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -328,7 +328,7 @@ CREATE OR REPLACE FUNCTION arrivals_func () -- BIOGRAPHY_DATA IF TG_OP = 'INSERT' - OR NEW.cycle <> OLD.cycle THEN + OR NEW.swelling <> OLD.swelling THEN -- Check that the cycle code is allowed, based on sex and age. DECLARE -- EVENTS @@ -374,7 +374,7 @@ CREATE OR REPLACE FUNCTION arrivals_func () , roles.role, roles.pid; IF a_sex = 'sdb_female' THEN - IF NEW.cycle = 'sdb_male_swelling' THEN + IF NEW.swelling = 'sdb_male_swelling' THEN -- The sdb_male_swelling code (n/a) cannot be assigned to -- females. RAISE EXCEPTION integrity_constraint_violation USING @@ -384,8 +384,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () || ' state' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -417,7 +417,7 @@ CREATE OR REPLACE FUNCTION arrivals_func () AND a_animid <> 'sdb_stranger_female2' AND a_animid <> 'sdb_stranger_female3' THEN - IF NEW.cycle = 'sdb_adolescent_swelling' THEN + IF NEW.swelling = 'sdb_adolescent_swelling' THEN -- The sdb_adolescent_swelling code (U) can only be assigned to -- adolescent females. @@ -436,8 +436,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () || ' cycle state' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -484,8 +484,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () || ' cycle state' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -514,8 +514,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () , HINT = 'sdb_follow_age_hint'; END IF; -- End of adolescent swelling - ELSIF NEW.cycle <> 'sdb_no_swelling' - AND NEW.cycle <> 'sdb_missing_swelling' THEN + ELSIF NEW.swelling <> 'sdb_no_swelling' + AND NEW.swelling <> 'sdb_missing_swelling' THEN -- Not sdb_male_swelling and not sdb_adolescent_swelling -- and not sdb_no_swelling and not sdb_missing_swelling. -- The other swelling codes indicate some swelling and can @@ -535,8 +535,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () || ' sexual swelling' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -581,8 +581,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () || ' sexual swelling' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -618,7 +618,7 @@ CREATE OR REPLACE FUNCTION arrivals_func () -- Only the sdb_male_swelling code (n/a) can be assigned -- to non-females. - IF NEW.cycle <> 'sdb_male_swelling' THEN + IF NEW.swelling <> 'sdb_male_swelling' THEN RAISE EXCEPTION integrity_constraint_violation USING MESSAGE = 'Error on ' || TG_OP || ' of ARRIVALS' , DETAIL = 'A non-female must be assigned the' @@ -626,8 +626,8 @@ CREATE OR REPLACE FUNCTION arrivals_func () || ' cycle state' || ': Key (EID = (' || NEW.eid - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Key (ROLES.PID) = (' || a_pid || '), Value (ROLES.Role) = (' @@ -786,8 +786,8 @@ CREATE OR REPLACE FUNCTION arrivals_commit_func () || NEW.neststart || '): Value (NestEnd) = (' || NEW.nestend - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Value (datasource) = (' || NEW.datasource || '): Key (ROLES.PID) = (' @@ -861,8 +861,8 @@ CREATE OR REPLACE FUNCTION arrivals_commit_func () || NEW.neststart || '): Value (NestEnd) = (' || NEW.nestend - || '): Value (Cycle) = (' - || NEW.cycle + || '): Value (Swelling) = (' + || NEW.swelling || '): Value (datasource) = (' || NEW.datasource || '): Key (ROLES.PID) = (' -- 2.34.1