mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
TemplateVariables: Fix custom variable function support (#62509)
Validate query values
This commit is contained in:
parent
f23be415c5
commit
3ac97dd396
@ -24,6 +24,7 @@ import {
|
|||||||
import { toDataQueryError } from '@grafana/runtime';
|
import { toDataQueryError } from '@grafana/runtime';
|
||||||
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
|
||||||
import { backendSrv } from 'app/core/services/backend_srv';
|
import { backendSrv } from 'app/core/services/backend_srv';
|
||||||
|
import { queryIsEmpty } from 'app/core/utils/query';
|
||||||
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
|
import { dataSource as expressionDatasource } from 'app/features/expressions/ExpressionDatasource';
|
||||||
import { ExpressionQuery } from 'app/features/expressions/types';
|
import { ExpressionQuery } from 'app/features/expressions/types';
|
||||||
|
|
||||||
@ -176,10 +177,14 @@ export function callQueryMethod(
|
|||||||
queryFunction?: typeof datasource.query
|
queryFunction?: typeof datasource.query
|
||||||
) {
|
) {
|
||||||
// If the datasource has defined a default query, make sure it's applied
|
// If the datasource has defined a default query, make sure it's applied
|
||||||
request.targets = request.targets.map((t) => ({
|
request.targets = request.targets.map((t) =>
|
||||||
...datasource?.getDefaultQuery?.(CoreApp.PanelEditor),
|
queryIsEmpty(t)
|
||||||
...t,
|
? {
|
||||||
}));
|
...datasource?.getDefaultQuery?.(CoreApp.PanelEditor),
|
||||||
|
...t,
|
||||||
|
}
|
||||||
|
: t
|
||||||
|
);
|
||||||
|
|
||||||
// If its a public datasource, just return the result. Expressions will be handled on the backend.
|
// If its a public datasource, just return the result. Expressions will be handled on the backend.
|
||||||
if (datasource.type === 'public-ds') {
|
if (datasource.type === 'public-ds') {
|
||||||
|
Loading…
Reference in New Issue
Block a user