浏览代码

add groupby when adding first aggregate

Sven Klemm 7 年之前
父节点
当前提交
9f0b4e0aa7
共有 1 个文件被更改,包括 4 次插入0 次删除
  1. 4 0
      public/app/plugins/datasource/postgres/query_ctrl.ts

+ 4 - 0
public/app/plugins/datasource/postgres/query_ctrl.ts

@@ -234,6 +234,10 @@ export class PostgresQueryCtrl extends QueryCtrl {
         this.selectModels.push(parts);
         this.selectModels.push(parts);
         break;
         break;
       case 'aggregate':
       case 'aggregate':
+        // add group by if no group by yet
+        if (this.target.groupBy.length === 0) {
+          this.addGroupBy('time', '1m');
+        }
       case 'special':
       case 'special':
         let index = _.findIndex(selectParts, (p: any) => p.def.type === item.value);
         let index = _.findIndex(selectParts, (p: any) => p.def.type === item.value);
         if (index !== -1) {
         if (index !== -1) {