mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
DataSources: Fixes issue with expressions not being queried (#50446)
This commit is contained in:
parent
a263a0f9bd
commit
ce1ee4de04
@ -26,6 +26,7 @@ import {
|
|||||||
transformDataFrame,
|
transformDataFrame,
|
||||||
} from '@grafana/data';
|
} from '@grafana/data';
|
||||||
import { getTemplateSrv } from '@grafana/runtime';
|
import { getTemplateSrv } from '@grafana/runtime';
|
||||||
|
import { ExpressionDatasourceRef } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||||
import { StreamingDataFrame } from 'app/features/live/data/StreamingDataFrame';
|
import { StreamingDataFrame } from 'app/features/live/data/StreamingDataFrame';
|
||||||
import { isStreamingDataFrame } from 'app/features/live/data/utils';
|
import { isStreamingDataFrame } from 'app/features/live/data/utils';
|
||||||
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
import { getDatasourceSrv } from 'app/features/plugins/datasource_srv';
|
||||||
@ -235,12 +236,13 @@ export class PanelQueryRunner {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
const ds = await getDataSource(datasource, request.scopedVars);
|
const ds = await getDataSource(datasource, request.scopedVars);
|
||||||
|
const isMixedDS = ds.meta?.mixed;
|
||||||
// Attach the data source to each query
|
// Attach the data source to each query
|
||||||
request.targets = request.targets.map((query) => {
|
request.targets = request.targets.map((query) => {
|
||||||
|
const isExpressionQuery = query.datasource?.type === ExpressionDatasourceRef.type;
|
||||||
// When using a data source variable, the panel might have the incorrect 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
|
// 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)) {
|
if (!query.datasource || (query.datasource.uid !== ds.uid && !isMixedDS && !isExpressionQuery)) {
|
||||||
query.datasource = ds.getRef();
|
query.datasource = ds.getRef();
|
||||||
}
|
}
|
||||||
return query;
|
return query;
|
||||||
|
Loading…
Reference in New Issue
Block a user