فهرست منبع

fix(influxdb_09): fixed handling of regex measurement in explore queries, fixes #2415

Torkel Ödegaard 10 سال پیش
والد
کامیت
7cae087eb9
2فایلهای تغییر یافته به همراه10 افزوده شده و 1 حذف شده
  1. 4 1
      public/app/plugins/datasource/influxdb/queryBuilder.js
  2. 6 0
      public/test/specs/influx09-querybuilder-specs.js

+ 4 - 1
public/app/plugins/datasource/influxdb/queryBuilder.js

@@ -44,7 +44,10 @@ function (_) {
     }
 
     if (measurement) {
-      query += ' FROM "' + measurement + '"';
+      if (!measurement.match('^/.*/') && !measurement.match(/^merge\(.*\)/)) {
+        measurement = '"' + measurement+ '"';
+      }
+      query += ' FROM ' + measurement;
     }
 
     if (withKey) {

+ 6 - 0
public/test/specs/influx09-querybuilder-specs.js

@@ -102,6 +102,12 @@ define([
         expect(query).to.be('SHOW TAG KEYS FROM "cpu"');
       });
 
+      it('should handle regex measurement in tag keys query', function() {
+        var builder = new InfluxQueryBuilder({ measurement: '/.*/', tags: [] });
+        var query = builder.buildExploreQuery('TAG_KEYS');
+        expect(query).to.be('SHOW TAG KEYS FROM /.*/');
+      });
+
       it('should have no conditions in tags keys query given query with no measurement or tag', function() {
         var builder = new InfluxQueryBuilder({ measurement: '', tags: [] });
         var query = builder.buildExploreQuery('TAG_KEYS');