Parcourir la source

Graphite: Fix for graphite expressions parser failure when metric expressions starts with curly brace segment, Fixes #528

Torkel Ödegaard il y a 11 ans
Parent
commit
586399a814
3 fichiers modifiés avec 15 ajouts et 3 suppressions
  1. 1 0
      CHANGELOG.md
  2. 5 2
      src/app/services/graphite/parser.js
  3. 9 1
      src/test/specs/parser-specs.js

+ 1 - 0
CHANGELOG.md

@@ -25,6 +25,7 @@
 - [Issue #545](https://github.com/grafana/grafana/issues/545). Chart: Fix formatting negative values (axis formats, legend values)
 - [Issue #460](https://github.com/grafana/grafana/issues/460). Chart: fix for max legend value when max value is zero
 - [Issue #628](https://github.com/grafana/grafana/issues/628). Filtering: Fix for nested filters, changing a child filter could result in infinite recursion in some cases
+- [Issue #528](https://github.com/grafana/grafana/issues/528). Graphite: Fix for graphite expressions parser failure when metric expressions starts with curly brace segment
 
 # 1.6.1 (2014-06-24)
 

+ 5 - 2
src/app/services/graphite/parser.js

@@ -97,7 +97,10 @@ define([
     },
 
     metricExpression: function() {
-      if (!this.match('templateStart') && !this.match('identifier') && !this.match('number')) {
+      if (!this.match('templateStart') &&
+          !this.match('identifier') &&
+          !this.match('number') &&
+          !this.match('{')) {
         return null;
       }
 
@@ -221,4 +224,4 @@ define([
   };
 
   return Parser;
-});
+});

+ 9 - 1
src/test/specs/parser-specs.js

@@ -140,7 +140,7 @@ define([
       expect(rootNode.type).to.be('function');
     });
 
-     it('handle float function arguments', function() {
+    it('handle float function arguments', function() {
       var parser = new Parser('scale(test, 0.002)');
       var rootNode = parser.getAst();
       expect(rootNode.type).to.be('function');
@@ -148,6 +148,14 @@ define([
       expect(rootNode.params[1].value).to.be(0.002);
     });
 
+    it('handle curly brace pattern at start', function() {
+      var parser = new Parser('{apps}.test');
+      var rootNode = parser.getAst();
+      expect(rootNode.type).to.be('metric');
+      expect(rootNode.segments[0].value).to.be('{apps}');
+      expect(rootNode.segments[1].value).to.be('test');
+    });
+
   });
 
 });