Variables: Fixes issue with data source variables not being correctly used in panel queries (#49323)

This commit is contained in:
Joao Silva
2022-05-26 11:39:47 +01:00
committed by GitHub
parent 9b61d9eb1c
commit 8c477a288a

View File

@@ -236,9 +236,11 @@ export class PanelQueryRunner {
try { try {
const ds = await getDataSource(datasource, request.scopedVars); const ds = await getDataSource(datasource, request.scopedVars);
// Attach the data source name to each query // Attach the data source to each query
request.targets = request.targets.map((query) => { request.targets = request.targets.map((query) => {
if (!query.datasource) { // When using a data source variable, the panel might have the incorrect datasource
// stored, so when running the query make sure it is done with the correct one
if (!query.datasource || (query.datasource.uid !== ds.uid && !ds.meta.mixed)) {
query.datasource = ds.getRef(); query.datasource = ds.getRef();
} }
return query; return query;