mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove extra sql select from the Insert function of userimpl.store (#87060)
Remove getAnyUserType
This commit is contained in:
parent
0f4db3f5ad
commit
1cb3f332a1
@ -75,11 +75,6 @@ func (ss *sqlStore) Insert(ctx context.Context, cmd *user.User) (int64, error) {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// verify that user was created and cmd.ID was updated with the actual new userID
|
||||
_, err = ss.getAnyUserType(ctx, cmd.ID)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
return cmd.ID, nil
|
||||
}
|
||||
|
||||
@ -588,22 +583,6 @@ func (ss *sqlStore) Search(ctx context.Context, query *user.SearchUsersQuery) (*
|
||||
return &result, err
|
||||
}
|
||||
|
||||
// getAnyUserType searches for a user record by ID. The user account may be a service account.
|
||||
func (ss *sqlStore) getAnyUserType(ctx context.Context, userID int64) (*user.User, error) {
|
||||
usr := user.User{ID: userID}
|
||||
err := ss.db.WithDbSession(ctx, func(sess *db.Session) error {
|
||||
has, err := sess.Get(&usr)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if !has {
|
||||
return user.ErrUserNotFound
|
||||
}
|
||||
return nil
|
||||
})
|
||||
return &usr, err
|
||||
}
|
||||
|
||||
func setOptional[T any](v *T, add func(v T)) {
|
||||
if v != nil {
|
||||
add(*v)
|
||||
|
Loading…
Reference in New Issue
Block a user