소스 검색

add alias when adding group by

Sven Klemm 7 년 전
부모
커밋
e8e24f6139
1개의 변경된 파일3개의 추가작업 그리고 0개의 파일을 삭제
  1. 3 0
      public/app/plugins/datasource/postgres/postgres_query.ts

+ 3 - 0
public/app/plugins/datasource/postgres/postgres_query.ts

@@ -101,6 +101,9 @@ export default class PostgresQuery {
       var selectParts = this.target.select[i];
       if (!selectParts.some(part => part.type === 'aggregate')) {
         selectParts.splice(1, 0, { type: 'aggregate', params: ['avg'] });
+        if (!selectParts.some(part => part.type === 'alias')) {
+          selectParts.push({ type: 'alias', params: [selectParts[0].params[0]] });
+        }
       }
     }