nil slices to empty

This commit is contained in:
crn4
2025-10-17 14:34:22 +02:00
parent f588997c49
commit d68eb8cc93
2 changed files with 16 additions and 0 deletions

View File

@@ -949,6 +949,8 @@ func (s *SqlStore) GetAccount(ctx context.Context, accountID string) (*types.Acc
} }
if autoGroups != nil { if autoGroups != nil {
_ = json.Unmarshal(autoGroups, &sk.AutoGroups) _ = json.Unmarshal(autoGroups, &sk.AutoGroups)
} else {
sk.AutoGroups = []string{}
} }
} }
return sk, err return sk, err
@@ -1077,6 +1079,8 @@ func (s *SqlStore) GetAccount(ctx context.Context, accountID string) (*types.Acc
} }
if autoGroups != nil { if autoGroups != nil {
_ = json.Unmarshal(autoGroups, &u.AutoGroups) _ = json.Unmarshal(autoGroups, &u.AutoGroups)
} else {
u.AutoGroups = []string{}
} }
} }
return u, err return u, err
@@ -1112,7 +1116,11 @@ func (s *SqlStore) GetAccount(ctx context.Context, accountID string) (*types.Acc
} }
if resources != nil { if resources != nil {
_ = json.Unmarshal(resources, &g.Resources) _ = json.Unmarshal(resources, &g.Resources)
} else {
g.Resources = []types.Resource{}
} }
g.GroupPeers = []types.GroupPeer{}
g.Peers = []string{}
} }
return &g, err return &g, err
}) })

View File

@@ -867,6 +867,8 @@ func (s *SqlStore) GetAccountPureSQL(ctx context.Context, accountID string) (*ty
} }
if autoGroups != nil { if autoGroups != nil {
_ = json.Unmarshal(autoGroups, &sk.AutoGroups) _ = json.Unmarshal(autoGroups, &sk.AutoGroups)
} else {
sk.AutoGroups = []string{}
} }
} }
return sk, err return sk, err
@@ -995,6 +997,8 @@ func (s *SqlStore) GetAccountPureSQL(ctx context.Context, accountID string) (*ty
} }
if autoGroups != nil { if autoGroups != nil {
_ = json.Unmarshal(autoGroups, &u.AutoGroups) _ = json.Unmarshal(autoGroups, &u.AutoGroups)
} else {
u.AutoGroups = []string{}
} }
} }
return u, err return u, err
@@ -1030,7 +1034,11 @@ func (s *SqlStore) GetAccountPureSQL(ctx context.Context, accountID string) (*ty
} }
if resources != nil { if resources != nil {
_ = json.Unmarshal(resources, &g.Resources) _ = json.Unmarshal(resources, &g.Resources)
} else {
g.Resources = []types.Resource{}
} }
g.GroupPeers = []types.GroupPeer{}
g.Peers = []string{}
} }
return &g, err return &g, err
}) })