From 60c2bc0be2de6cd8c9063a95a3ad2ba402f3e3eb Mon Sep 17 00:00:00 2001 From: Daniel Ponte Date: Sun, 28 Jul 2024 08:09:52 -0400 Subject: [PATCH] query iteration --- sql/postgres/migrations/001_initial.up.sql | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/sql/postgres/migrations/001_initial.up.sql b/sql/postgres/migrations/001_initial.up.sql index 4ca0c39..84a44c3 100644 --- a/sql/postgres/migrations/001_initial.up.sql +++ b/sql/postgres/migrations/001_initial.up.sql @@ -55,11 +55,10 @@ BEGIN WHERE talkgroups.system_id = NEW.system AND talkgroups.tgid = NEW.talkgroup AND ( - talkgroups.name != NEW.tg_label - OR NOT (talkgroups_tags.tags @> ARRAY[NEW.tg_tag]) - OR talkgroups.tg_group != NEW.tg_group + talkgroups.name = NEW.tg_label + AND (NEW.tg_tag IS NULL OR (talkgroups_tags.tags @> ARRAY[NEW.tg_tag])) + AND (NEW.tg_group IS NULL OR talkgroups.tg_group = NEW.tg_group) ) - AND talkgroups_learned.ignored IS NOT TRUE ) THEN INSERT INTO talkgroups_learned(system_id, tgid, group_name, group_tag) VALUES( NEW.system, NEW.talkgroup, NEW.tg_label, NEW.tg_tag