From 3a0c7bdea25cb370cb60af0bbb6def8b06e5137f Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sun, 25 Feb 2024 09:48:26 -0500 Subject: [PATCH] refactor: always preload all relations with exists --- account/account.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/account/account.go b/account/account.go index 9f6883e..46b510c 100644 --- a/account/account.go +++ b/account/account.go @@ -5,6 +5,8 @@ import ( "errors" "time" + "gorm.io/gorm/clause" + "git.lumeweb.com/LumeWeb/portal/config" "git.lumeweb.com/LumeWeb/portal/db/models" @@ -414,7 +416,7 @@ func (s AccountServiceDefault) updateAccountInfo(userId uint, info models.User) func (s AccountServiceDefault) exists(model interface{}, conditions map[string]interface{}) (bool, interface{}, error) { // Conduct a query with the provided model and conditions - result := s.db.Model(model).Where(conditions).First(model) + result := s.db.Preload(clause.Associations).Model(model).Where(conditions).First(model) // Check if any rows were found exists := result.RowsAffected > 0