Browse Source

dont run queries if target has no table set

Sven Klemm 7 years ago
parent
commit
7f348f3836
1 changed files with 5 additions and 1 deletions
  1. 5 1
      public/app/plugins/datasource/postgres/postgres_query.ts

+ 5 - 1
public/app/plugins/datasource/postgres/postgres_query.ts

@@ -17,7 +17,7 @@ export default class PostgresQuery {
     target.metricColumn = target.metricColumn || 'none';
 
     target.groupBy = target.groupBy || [];
-    target.where = target.where || [];
+    target.where = target.where || [{ type: 'macro', params: ['$__timeFilter'] }];
     target.select = target.select || [[{ type: 'column', params: ['value'] }]];
 
     // handle pre query gui panels gracefully
@@ -77,6 +77,10 @@ export default class PostgresQuery {
   render(interpolate?) {
     let target = this.target;
 
+    if (!('table' in this.target)) {
+      return '';
+    }
+
     if (!target.rawQuery) {
       target.rawSql = this.buildQuery();
     }