From b1b2b0adf000a29f259bc6583ea1153d1ff50bbd Mon Sep 17 00:00:00 2001 From: bcmmbaga Date: Thu, 26 Sep 2024 19:47:43 +0300 Subject: [PATCH] fix tests Signed-off-by: bcmmbaga --- management/server/sql_store.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/management/server/sql_store.go b/management/server/sql_store.go index 9e65ba9cf..85c68ef44 100644 --- a/management/server/sql_store.go +++ b/management/server/sql_store.go @@ -1055,14 +1055,18 @@ func (s *SqlStore) GetAccountDNSSettings(ctx context.Context, lockStrength Locki // AccountExists checks whether an account exists by the given ID. func (s *SqlStore) AccountExists(ctx context.Context, lockStrength LockingStrength, id string) (bool, error) { - var count int64 + var accountID string result := s.db.WithContext(ctx).Clauses(clause.Locking{Strength: string(lockStrength)}).Model(&Account{}). - Where(idQueryCondition, id).Count(&count) + Select("id").First(&accountID, idQueryCondition, id) if result.Error != nil { + if errors.Is(result.Error, gorm.ErrRecordNotFound) { + return false, nil + } return false, result.Error } - return count > 0, nil + + return accountID != "", nil } // GetAccountDomainAndCategory retrieves the Domain and DomainCategory fields for an account based on the given accountID.