瀏覽代碼

set query gui as default handle old panels gracefully

Sven Klemm 7 年之前
父節點
當前提交
0e610cad1b
共有 1 個文件被更改,包括 10 次插入4 次删除
  1. 10 4
      public/app/plugins/datasource/postgres/postgres_query.ts

+ 10 - 4
public/app/plugins/datasource/postgres/postgres_query.ts

@@ -27,7 +27,13 @@ export default class PostgresQuery {
 
 
     // handle pre query gui panels gracefully
     // handle pre query gui panels gracefully
     if (!('rawQuery' in this.target)) {
     if (!('rawQuery' in this.target)) {
-      target.rawQuery = true;
+      if ('rawSql' in target) {
+        // pre query gui panel
+        target.rawQuery = true;
+      } else {
+        // new panel
+        target.rawQuery = false;
+      }
     }
     }
 
 
     // give interpolateQueryStr access to this
     // give interpolateQueryStr access to this
@@ -55,10 +61,10 @@ export default class PostgresQuery {
 
 
   updateProjection() {
   updateProjection() {
     this.selectModels = _.map(this.target.select, function(parts: any) {
     this.selectModels = _.map(this.target.select, function(parts: any) {
-      return _.map(parts, sqlPart.create);
+      return _.map(parts, sqlPart.create).filter(n => n);
     });
     });
-    this.whereParts = _.map(this.target.where, sqlPart.create);
-    this.groupByParts = _.map(this.target.groupBy, sqlPart.create);
+    this.whereParts = _.map(this.target.where, sqlPart.create).filter(n => n);
+    this.groupByParts = _.map(this.target.groupBy, sqlPart.create).filter(n => n);
   }
   }
 
 
   updatePersistedParts() {
   updatePersistedParts() {