Skip to content

Commit 4244551

Browse files
committed
fix(influxdb): removes quotes for field key queries
fixes grafana#6473
1 parent 3a96809 commit 4244551

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

public/app/plugins/datasource/influxdb/query_builder.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ function (_) {
5656
query += ' WITH MEASUREMENT =~ /' + withMeasurementFilter +'/';
5757
}
5858
} else if (type === 'FIELDS') {
59-
query = 'SHOW FIELD KEYS FROM "' + this.target.measurement + '"';
60-
return query;
59+
if (!this.target.measurement.match('^/.*/')) {
60+
return 'SHOW FIELD KEYS FROM "' + this.target.measurement + '"';
61+
} else {
62+
return 'SHOW FIELD KEYS FROM ' + this.target.measurement;
63+
}
6164
} else if (type === 'RETENTION POLICIES') {
6265
query = 'SHOW RETENTION POLICIES on "' + this.database + '"';
6366
return query;

public/app/plugins/datasource/influxdb/specs/query_builder_specs.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,12 @@ describe('InfluxQueryBuilder', function() {
8888
expect(query).to.be('SHOW FIELD KEYS FROM "cpu"');
8989
});
9090

91+
it('should build show field query with regexp', function() {
92+
var builder = new InfluxQueryBuilder({measurement: '/$var/', tags: [{key: 'app', value: 'email'}]});
93+
var query = builder.buildExploreQuery('FIELDS');
94+
expect(query).to.be('SHOW FIELD KEYS FROM /$var/');
95+
});
96+
9197
it('should build show retention policies query', function() {
9298
var builder = new InfluxQueryBuilder({measurement: 'cpu', tags: []}, 'site');
9399
var query = builder.buildExploreQuery('RETENTION POLICIES');

0 commit comments

Comments
 (0)