add alias when adding group by

This commit is contained in:
Sven Klemm
2018-07-10 11:32:23 +02:00
parent 6e7161f238
commit e8e24f6139

View File

@ -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]] });
}
}
}