diff --git a/pkg/services/sqlstore/datasource.go b/pkg/services/sqlstore/datasource.go index fab74f05f8e..b41e56b10fe 100644 --- a/pkg/services/sqlstore/datasource.go +++ b/pkg/services/sqlstore/datasource.go @@ -121,7 +121,7 @@ func (ss *SQLStore) DeleteDataSource(ctx context.Context, cmd *datasources.Delet // Remove associated AccessControl permissions if _, errDeletingPerms := sess.Exec("DELETE FROM permission WHERE scope=?", - ac.Scope("datasources", "id", fmt.Sprint(dsQuery.Result.Id))); errDeletingPerms != nil { + ac.Scope(datasources.ScopeProvider.GetResourceScope(dsQuery.Result.Uid))); errDeletingPerms != nil { return errDeletingPerms } } diff --git a/pkg/services/sqlstore/datasource_test.go b/pkg/services/sqlstore/datasource_test.go index 34169f799a9..26848da0348 100644 --- a/pkg/services/sqlstore/datasource_test.go +++ b/pkg/services/sqlstore/datasource_test.go @@ -3,7 +3,6 @@ package sqlstore import ( "context" "errors" - "fmt" "strconv" "testing" "time" @@ -305,7 +304,7 @@ func TestIntegrationDataAccess(t *testing.T) { _, err := sess.Table("permission").Insert(ac.Permission{ RoleID: 1, Action: "datasources:read", - Scope: ac.Scope("datasources", "id", fmt.Sprintf("%d", ds.Id)), + Scope: datasources.ScopeProvider.GetResourceScope(ds.Uid), Updated: time.Now(), Created: time.Now(), })