From b4093e8152a359e08b7960fd8a87f614928ad361 Mon Sep 17 00:00:00 2001 From: Kenneth Kehl <@kkehl@flexion.us> Date: Tue, 3 Dec 2024 12:55:52 -0800 Subject: [PATCH] change create notification to an upsert --- app/dao/notifications_dao.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/app/dao/notifications_dao.py b/app/dao/notifications_dao.py index 4c40a7e81..d231ece42 100644 --- a/app/dao/notifications_dao.py +++ b/app/dao/notifications_dao.py @@ -73,7 +73,10 @@ def dao_create_notification(notification): notification.normalised_to = "1" # notify-api-1454 change to an upsert - db.session.merge(notification) + stmt = select(Notification).where(Notification.id == notification.id) + result = db.session.execute(stmt).scalar() + if result is None: + db.session.add(notification) def country_records_delivery(phone_prefix):