Skip to content

Commit

Permalink
TemplateVariables: Fix custom variable function support (#62509)
Browse files Browse the repository at this point in the history
Validate query values
  • Loading branch information
aangelisc authored Jan 30, 2023
1 parent f23be41 commit 3ac97dd
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions public/app/features/query/state/runRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { toDataQueryError } from '@grafana/runtime';
import { isExpressionReference } from '@grafana/runtime/src/utils/DataSourceWithBackend';
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 { ExpressionQuery } from 'app/features/expressions/types';

Expand Down Expand Up @@ -176,10 +177,14 @@ export function callQueryMethod(
queryFunction?: typeof datasource.query
) {
// If the datasource has defined a default query, make sure it's applied
request.targets = request.targets.map((t) => ({
...datasource?.getDefaultQuery?.(CoreApp.PanelEditor),
...t,
}));
request.targets = request.targets.map((t) =>
queryIsEmpty(t)
? {
...datasource?.getDefaultQuery?.(CoreApp.PanelEditor),
...t,
}
: t
);

// If its a public datasource, just return the result. Expressions will be handled on the backend.
if (datasource.type === 'public-ds') {
Expand Down

0 comments on commit 3ac97dd

Please sign in to comment.