From db89056468820b7fa171cc14399c63a1081aaec6 Mon Sep 17 00:00:00 2001 From: Frederick Holland Date: Thu, 23 Oct 2025 17:02:52 +1100 Subject: [PATCH] Added BeforeSave --- models/participant.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/models/participant.go b/models/participant.go index f4c4439..cca5e5d 100644 --- a/models/participant.go +++ b/models/participant.go @@ -2,6 +2,8 @@ package models import ( "time" + + "gorm.io/gorm" ) type DBParticipant struct { @@ -30,3 +32,11 @@ type DBParticipant struct { func (DBParticipant) TableName() string { return "gc_participants" } + +func (p *DBParticipant) BeforeSave(tx *gorm.DB) error { + // Convert empty string to nil + if p.UserId != nil && *p.UserId == "" { + p.UserId = nil + } + return nil +}