MSSQL/MySQL: Add correct refId when fetching variable query results (#56919)

pull/56986/head
Victor Marin 3 years ago committed by GitHub
parent 902a230867
commit b374b01260
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      public/app/features/plugins/sql/datasource/SqlDatasource.ts

@ -106,6 +106,11 @@ export abstract class SqlDatasource extends DataSourceWithBackend<SQLQuery, SQLO
}
async metricFindQuery(query: string, optionalOptions?: MetricFindQueryOptions): Promise<MetricFindValue[]> {
let refId = 'tempvar';
if (optionalOptions && optionalOptions.variable && optionalOptions.variable.name) {
refId = optionalOptions.variable.name;
}
const rawSql = this.templateSrv.replace(
query,
getSearchFilterScopedVar({ query, wildcardChar: '%', options: optionalOptions }),
@ -113,7 +118,7 @@ export abstract class SqlDatasource extends DataSourceWithBackend<SQLQuery, SQLO
);
const interpolatedQuery: SQLQuery = {
refId: 'tempvar',
refId: refId,
datasource: this.getRef(),
rawSql,
format: QueryFormat.Table,
@ -200,4 +205,5 @@ interface RunSQLOptions extends MetricFindQueryOptions {
interface MetricFindQueryOptions extends SearchFilterOptions {
range?: TimeRange;
variable?: VariableWithMultiSupport;
}

Loading…
Cancel
Save