From 3065be4a7e9d5b59b13677d2c21304ba61da8f46 Mon Sep 17 00:00:00 2001 From: Andreas Christou Date: Wed, 19 Feb 2025 17:07:25 +0000 Subject: [PATCH] Revert "InfluxDB: Improve handling of template variables contained in regular expressions (InfluxQL) (#100762)" This reverts commit 8c525e68dafcd5b8c340834a0050aa23bd1516bb. --- .../datasource/influxdb/datasource.test.ts | 12 ---------- .../plugins/datasource/influxdb/datasource.ts | 23 ++++--------------- 2 files changed, 5 insertions(+), 30 deletions(-) diff --git a/public/app/plugins/datasource/influxdb/datasource.test.ts b/public/app/plugins/datasource/influxdb/datasource.test.ts index 284717ac701..b2cdd4522e3 100644 --- a/public/app/plugins/datasource/influxdb/datasource.test.ts +++ b/public/app/plugins/datasource/influxdb/datasource.test.ts @@ -363,18 +363,6 @@ describe('interpolateQueryExpr', () => { expect(result).toBe(expectation); }); - it('should **not** return the escaped value if the value **is not** wrapped in regex and the query is more complex (e.g. text is contained between two / but not a regex', () => { - const value = 'testmatch'; - const variableMock = queryBuilder().withId('tempVar').withName('tempVar').withMulti(false).build(); - const result = ds.interpolateQueryExpr( - value, - variableMock, - `select value where ("tag"::tag =~ /value/) AND where other = $tempVar $timeFilter GROUP BY time($__interval) tz('Europe/London')` - ); - const expectation = `testmatch`; - expect(result).toBe(expectation); - }); - it('should return floating point number as it is', () => { const variableMock = queryBuilder() .withId('tempVar') diff --git a/public/app/plugins/datasource/influxdb/datasource.ts b/public/app/plugins/datasource/influxdb/datasource.ts index a0be6d90bf3..1292ac4b625 100644 --- a/public/app/plugins/datasource/influxdb/datasource.ts +++ b/public/app/plugins/datasource/influxdb/datasource.ts @@ -351,30 +351,17 @@ export default class InfluxDatasource extends DataSourceWithBackend escapeRegex(v)).join('|')})`; + return `(${value.map((v) => escapeRegex(v)).join('|')})`; } return value;