Browse Source

Fix: Graphite query rendering fix (#16390)

Only interpolate string parameters

Fixes #16367
Torkel Ödegaard 6 years ago
parent
commit
173e7fd839

+ 2 - 1
public/app/plugins/datasource/graphite/gfunc.ts

@@ -966,7 +966,6 @@ export class FuncInstance {
     const str = this.def.name + '(';
     const str = this.def.name + '(';
 
 
     const parameters = _.map(this.params, (value, index) => {
     const parameters = _.map(this.params, (value, index) => {
-      const valueInterpolated = replaceVariables(value);
       let paramType;
       let paramType;
 
 
       if (index < this.def.params.length) {
       if (index < this.def.params.length) {
@@ -980,6 +979,8 @@ export class FuncInstance {
         return value;
         return value;
       }
       }
 
 
+      const valueInterpolated = _.isString(value) ? replaceVariables(value) : value;
+
       // param types that might be quoted
       // param types that might be quoted
       // To quote variables correctly we need to interpolate it to check if it contains a numeric or string value
       // To quote variables correctly we need to interpolate it to check if it contains a numeric or string value
       if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+valueInterpolated)) {
       if (_.includes(['int_or_interval', 'node_or_tag'], paramType) && _.isFinite(+valueInterpolated)) {

+ 2 - 1
public/app/plugins/datasource/graphite/specs/gfunc.test.ts

@@ -31,7 +31,8 @@ describe('when creating func instance from func names', () => {
 });
 });
 
 
 function replaceVariablesDummy(str: string) {
 function replaceVariablesDummy(str: string) {
-  return str;
+  // important that this does replace
+  return str.replace('asdasdas', 'asdsad');
 }
 }
 
 
 describe('when rendering func instance', () => {
 describe('when rendering func instance', () => {