[v9.4.x] Plugins: Prefer to use the data source UID when querying (#62789)
Plugins: Prefer to use the data source UID when querying (#62776)
(cherry picked from commit 68862ce3e8)
Co-authored-by: Andres Martinez Gotor <andres.martinez@grafana.com>
This commit is contained in:
co-authored by
Andres Martinez Gotor
parent
022abcb47d
commit
190c3aad58
@@ -322,18 +322,18 @@ func (s *Service) getDataSourceFromQuery(ctx context.Context, user *user.SignedI
|
||||
return grafanads.DataSourceModel(user.OrgID), nil
|
||||
}
|
||||
|
||||
// use datasourceId if it exists
|
||||
id := query.Get("datasourceId").MustInt64(0)
|
||||
if id > 0 {
|
||||
ds, err = s.dataSourceCache.GetDatasource(ctx, id, user, skipCache)
|
||||
if uid != "" {
|
||||
ds, err = s.dataSourceCache.GetDatasourceByUID(ctx, uid, user, skipCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return ds, nil
|
||||
}
|
||||
|
||||
if uid != "" {
|
||||
ds, err = s.dataSourceCache.GetDatasourceByUID(ctx, uid, user, skipCache)
|
||||
// use datasourceId if it exists
|
||||
id := query.Get("datasourceId").MustInt64(0)
|
||||
if id > 0 {
|
||||
ds, err = s.dataSourceCache.GetDatasource(ctx, id, user, skipCache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user