From 89a5e36a1e165b6057da19b380bab0231b397da5 Mon Sep 17 00:00:00 2001 From: Harshit Raj Date: Tue, 1 Aug 2023 09:38:05 +0530 Subject: [PATCH] Fix server crash --- application/db.events.go | 5 +++++ application/util.calendar.go | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/application/db.events.go b/application/db.events.go index b0137f9..0e1f73b 100644 --- a/application/db.events.go +++ b/application/db.events.go @@ -35,6 +35,11 @@ func updateEvent(ctx *gin.Context, event *ProformaEvent) error { return tx.Error } +func updateEventCalID(event *ProformaEvent) error { + tx := db.Clauses(clause.Returning{}).Where("id = ?", event.ID).Updates(event) + return tx.Error +} + func deleteEvent(ctx *gin.Context, id uint) error { tx := db.WithContext(ctx).Where("id = ?", id).Delete(&ProformaEvent{}) return tx.Error diff --git a/application/util.calendar.go b/application/util.calendar.go index 10459de..85f1ba8 100644 --- a/application/util.calendar.go +++ b/application/util.calendar.go @@ -43,7 +43,7 @@ func insertCalenderEvent(event *ProformaEvent, proforma *Proforma, loc *time.Loc } event.CalID = cevent.Id - err = updateEvent(nil, event) + err = updateEventCalID(event) if err != nil { logrus.Errorf("Unable to update event. %v", err) } @@ -86,7 +86,7 @@ func insertCalenderApplicationDeadline(proforma *Proforma, event *ProformaEvent) } event.CalID = cevent.Id - err = updateEvent(nil, event) + err = updateEventCalID(event) if err != nil { logrus.Errorf("Unable to update event. %v", err) }