From fe0b7533a1e4c4a955a1acdff5eda23f996d4120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 3 May 2016 10:25:06 +0200 Subject: [PATCH] fix(influxdb): quote number valued tag values, only not quote when operator is > or <, fixes #4885 --- .../app/plugins/datasource/influxdb/influx_query.ts | 2 +- .../datasource/influxdb/specs/influx_query_specs.ts | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/public/app/plugins/datasource/influxdb/influx_query.ts b/public/app/plugins/datasource/influxdb/influx_query.ts index 301d40a2edb..ff003859277 100644 --- a/public/app/plugins/datasource/influxdb/influx_query.ts +++ b/public/app/plugins/datasource/influxdb/influx_query.ts @@ -152,7 +152,7 @@ export default class InfluxQuery { if (interpolate) { value = this.templateSrv.replace(value, this.scopedVars); } - if (isNaN(+value)) { + if (operator !== '>' && operator !== '<') { value = "'" + value.replace('\\', '\\\\') + "'"; } } else if (interpolate){ diff --git a/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts b/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts index 157b9ed206a..557c626a7cc 100644 --- a/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts +++ b/public/app/plugins/datasource/influxdb/specs/influx_query_specs.ts @@ -101,6 +101,19 @@ describe('InfluxQuery', function() { }); }); + describe('query with value condition', function() { + it('should not quote value', function() { + var query = new InfluxQuery({ + measurement: 'cpu', + groupBy: [], + tags: [{key: 'value', value: '5', operator: '>'}] + }, templateSrv, {}); + + var queryText = query.render(); + expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE "value" > 5 AND $timeFilter'); + }); + }); + describe('series with groupByTag', function() { it('should generate correct query', function() { var query = new InfluxQuery({