Просмотр исходного кода

add alias when adding group by

Sven Klemm 7 лет назад
Родитель
Сommit
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]] });
+        }
       }
     }