InfluxDB: Fix measurement interpolation on visual query builder (#85423)

* fix measurement interpolation

* fix unit test

* fix unit test 2
This commit is contained in:
ismail simsek 2024-04-02 12:29:49 +02:00 committed by GitHub
parent b0aa575643
commit 64236a3923
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 8 additions and 3 deletions

View File

@ -289,7 +289,7 @@ describe('InfluxDataSource Frontend Mode', () => {
function influxChecks(query: InfluxQuery) {
expect(templateSrv.replace).toBeCalledTimes(12);
expect(query.alias).toBe(text);
expect(query.measurement).toBe(justText);
expect(query.measurement).toBe(textWithFormatRegex);
expect(query.policy).toBe(justText);
expect(query.limit).toBe(justText);
expect(query.slimit).toBe(justText);

View File

@ -297,7 +297,12 @@ export default class InfluxDatasource extends DataSourceWithBackend<InfluxQuery,
), // The raw sql query text
alias: this.templateSrv.replace(query.alias ?? '', scopedVars),
limit: this.templateSrv.replace(query.limit?.toString() ?? '', scopedVars),
measurement: this.templateSrv.replace(query.measurement ?? '', scopedVars),
measurement: this.templateSrv.replace(
query.measurement ?? '',
scopedVars,
(value: string | string[] = [], variable: QueryVariableModel) =>
this.interpolateQueryExpr(value, variable, query.measurement)
),
policy: this.templateSrv.replace(query.policy ?? '', scopedVars),
slimit: this.templateSrv.replace(query.slimit?.toString() ?? '', scopedVars),
tz: this.templateSrv.replace(query.tz ?? '', scopedVars),

View File

@ -180,7 +180,7 @@ describe('InfluxDataSource Backend Mode', () => {
function influxChecks(query: InfluxQuery) {
expect(templateSrv.replace).toBeCalledTimes(12);
expect(query.alias).toBe(text);
expect(query.measurement).toBe(justText);
expect(query.measurement).toBe(textWithFormatRegex);
expect(query.policy).toBe(justText);
expect(query.limit).toBe(justText);
expect(query.slimit).toBe(justText);