Browse Source

call render in query

Sven Klemm 8 năm trước cách đây
mục cha
commit
17be31e216
1 tập tin đã thay đổi với 9 bổ sung6 xóa
  1. 9 6
      public/app/plugins/datasource/postgres/datasource.ts

+ 9 - 6
public/app/plugins/datasource/postgres/datasource.ts

@@ -1,5 +1,6 @@
 import _ from 'lodash';
 import ResponseParser from './response_parser';
+import PostgresQuery from 'app/plugins/datasource/postgres/postgres_query';
 
 export class PostgresDatasource {
   id: any;
@@ -33,16 +34,18 @@ export class PostgresDatasource {
   }
 
   query(options) {
-    var queries = _.filter(options.targets, item => {
-      return item.hide !== true;
-    }).map(item => {
+    var queries = _.filter(options.targets, target => {
+      return target.hide !== true;
+    }).map(target => {
+      var queryModel = new PostgresQuery(target, this.templateSrv, options.scopedVars);
+
       return {
-        refId: item.refId,
+        refId: target.refId,
         intervalMs: options.intervalMs,
         maxDataPoints: options.maxDataPoints,
         datasourceId: this.id,
-        rawSql: this.templateSrv.replace(item.rawSql, options.scopedVars, this.interpolateVariable),
-        format: item.format,
+        rawSql: queryModel.render(this.interpolateVariable),
+        format: target.format,
       };
     });