add groupby when adding first aggregate

This commit is contained in:
Sven Klemm 2018-07-18 13:29:47 +02:00
parent 0e608a08c2
commit 9f0b4e0aa7

View File

@ -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) {