diff --git a/lib/FindQueryBuilder.js b/lib/FindQueryBuilder.js index 4a64bac..80ffc4a 100644 --- a/lib/FindQueryBuilder.js +++ b/lib/FindQueryBuilder.js @@ -437,9 +437,13 @@ class FindQueryBuilder { */ _buildGroupBy(params, builder) { const groupByParam = _.find(params, { key: 'groupBy' }); + const joinParam = _.find(builder._operations, { name: 'innerJoin' }); + const idColumn = this._modelClass.idColumn; + if (groupByParam) { - builder.select(groupByParam.value.split(',')); builder.groupBy(groupByParam.value.split(',')); + } else if (joinParam) { + builder.groupBy(Array.isArray(idColumn) ? idColumn : idColumn.split(',')); } }