diff --git a/pkg/services/sqlstore/alert_notification.go b/pkg/services/sqlstore/alert_notification.go index c8c515e81ee..ee780c53a44 100644 --- a/pkg/services/sqlstore/alert_notification.go +++ b/pkg/services/sqlstore/alert_notification.go @@ -54,7 +54,7 @@ func (ss *SQLStore) DeleteAlertNotification(ctx context.Context, cmd *models.Del func (ss *SQLStore) DeleteAlertNotificationWithUid(ctx context.Context, cmd *models.DeleteAlertNotificationWithUidCommand) error { existingNotification := &models.GetAlertNotificationsWithUidQuery{OrgId: cmd.OrgId, Uid: cmd.Uid} - if err := getAlertNotificationWithUidInternal(ctx, existingNotification, newSession(ctx)); err != nil { + if err := getAlertNotificationWithUidInternal(ctx, existingNotification, ss.newSession(ctx)); err != nil { return err } @@ -75,7 +75,7 @@ func (ss *SQLStore) DeleteAlertNotificationWithUid(ctx context.Context, cmd *mod } func (ss *SQLStore) GetAlertNotifications(ctx context.Context, query *models.GetAlertNotificationsQuery) error { - return getAlertNotificationInternal(ctx, query, newSession(ctx)) + return getAlertNotificationInternal(ctx, query, ss.newSession(ctx)) } func (ss *SQLStore) GetAlertNotificationUidWithId(ctx context.Context, query *models.GetAlertNotificationUidQuery) error { @@ -86,7 +86,7 @@ func (ss *SQLStore) GetAlertNotificationUidWithId(ctx context.Context, query *mo return nil } - err := getAlertNotificationUidInternal(ctx, query, newSession(ctx)) + err := getAlertNotificationUidInternal(ctx, query, ss.newSession(ctx)) if err != nil { return err } @@ -101,7 +101,7 @@ func newAlertNotificationUidCacheKey(orgID, notificationId int64) string { } func (ss *SQLStore) GetAlertNotificationsWithUid(ctx context.Context, query *models.GetAlertNotificationsWithUidQuery) error { - return getAlertNotificationWithUidInternal(ctx, query, newSession(ctx)) + return getAlertNotificationWithUidInternal(ctx, query, ss.newSession(ctx)) } func (ss *SQLStore) GetAllAlertNotifications(ctx context.Context, query *models.GetAllAlertNotificationsQuery) error { @@ -440,7 +440,7 @@ func (ss *SQLStore) UpdateAlertNotification(ctx context.Context, cmd *models.Upd func (ss *SQLStore) UpdateAlertNotificationWithUid(ctx context.Context, cmd *models.UpdateAlertNotificationWithUidCommand) error { getAlertNotificationWithUidQuery := &models.GetAlertNotificationsWithUidQuery{OrgId: cmd.OrgId, Uid: cmd.Uid} - if err := getAlertNotificationWithUidInternal(ctx, getAlertNotificationWithUidQuery, newSession(ctx)); err != nil { + if err := getAlertNotificationWithUidInternal(ctx, getAlertNotificationWithUidQuery, ss.newSession(ctx)); err != nil { return err } diff --git a/pkg/services/sqlstore/session.go b/pkg/services/sqlstore/session.go index dfa7c5fbe0a..556b936d4d1 100644 --- a/pkg/services/sqlstore/session.go +++ b/pkg/services/sqlstore/session.go @@ -30,8 +30,8 @@ func (ss *SQLStore) NewSession(ctx context.Context) *DBSession { return sess } -func newSession(ctx context.Context) *DBSession { - sess := &DBSession{Session: x.NewSession()} +func (ss *SQLStore) newSession(ctx context.Context) *DBSession { + sess := &DBSession{Session: ss.engine.NewSession()} sess.Session = sess.Session.Context(ctx) return sess diff --git a/pkg/services/sqlstore/tags_test.go b/pkg/services/sqlstore/tags_test.go index f1b986ded62..6fceef6308c 100644 --- a/pkg/services/sqlstore/tags_test.go +++ b/pkg/services/sqlstore/tags_test.go @@ -13,7 +13,7 @@ import ( ) func TestSavingTags(t *testing.T) { - InitTestDB(t) + ss := InitTestDB(t) tagPairs := []*models.Tag{ {Key: "outage"}, @@ -21,7 +21,7 @@ func TestSavingTags(t *testing.T) { {Key: "server", Value: "server-1"}, {Key: "error"}, } - tags, err := EnsureTagsExist(newSession(context.Background()), tagPairs) + tags, err := EnsureTagsExist(ss.newSession(context.Background()), tagPairs) require.Nil(t, err) require.Equal(t, 4, len(tags))