Commit fe0b7533 by Torkel Ödegaard

fix(influxdb): quote number valued tag values, only not quote when operator is > or <, fixes #4885

parent 152e0853
...@@ -152,7 +152,7 @@ export default class InfluxQuery { ...@@ -152,7 +152,7 @@ export default class InfluxQuery {
if (interpolate) { if (interpolate) {
value = this.templateSrv.replace(value, this.scopedVars); value = this.templateSrv.replace(value, this.scopedVars);
} }
if (isNaN(+value)) { if (operator !== '>' && operator !== '<') {
value = "'" + value.replace('\\', '\\\\') + "'"; value = "'" + value.replace('\\', '\\\\') + "'";
} }
} else if (interpolate){ } else if (interpolate){
......
...@@ -101,6 +101,19 @@ describe('InfluxQuery', function() { ...@@ -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() { describe('series with groupByTag', function() {
it('should generate correct query', function() { it('should generate correct query', function() {
var query = new InfluxQuery({ var query = new InfluxQuery({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment