mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
SQLStore: Close session in withDbSession (#31775)
* SQLStore: Close session in withDbSession Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com> * SQLStore.WithDbSession: Never use session from context Signed-off-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
@@ -28,13 +28,17 @@ func GetApiKeys(query *models.GetApiKeysQuery) error {
|
||||
}
|
||||
|
||||
func DeleteApiKeyCtx(ctx context.Context, cmd *models.DeleteApiKeyCommand) error {
|
||||
return withDbSession(ctx, func(sess *DBSession) error {
|
||||
var rawSQL = "DELETE FROM api_key WHERE id=? and org_id=?"
|
||||
_, err := sess.Exec(rawSQL, cmd.Id, cmd.OrgId)
|
||||
return err
|
||||
return withDbSession(ctx, x, func(sess *DBSession) error {
|
||||
return deleteAPIKey(sess, cmd.Id, cmd.OrgId)
|
||||
})
|
||||
}
|
||||
|
||||
func deleteAPIKey(sess *DBSession, id, orgID int64) error {
|
||||
rawSQL := "DELETE FROM api_key WHERE id=? and org_id=?"
|
||||
_, err := sess.Exec(rawSQL, id, orgID)
|
||||
return err
|
||||
}
|
||||
|
||||
func AddApiKey(cmd *models.AddApiKeyCommand) error {
|
||||
return inTransaction(func(sess *DBSession) error {
|
||||
key := models.ApiKey{OrgId: cmd.OrgId, Name: cmd.Name}
|
||||
|
||||
Reference in New Issue
Block a user