entc/gen: add Aggregate to <T>Select and <T>Query

This commit is contained in:
Ariel Mashraki
2022-10-22 22:39:13 +03:00
committed by Ariel Mashraki
parent 1bc4d48a51
commit 765ec09d31
165 changed files with 2629 additions and 226 deletions

View File

@@ -36,8 +36,7 @@ func ({{ $receiver }} *{{ $builder }}) sqlQuery() *sql.Selector {
for _, fn := range {{ $receiver }}.fns {
aggregation = append(aggregation, fn(selector))
}
// If no columns were selected in a custom aggregation function, the default
// selection is the fields used for "group-by", and the aggregation functions.
{{- /* If no columns were selected, the default selection is the fields used for "group-by", and the aggregation functions.*/}}
if len(selector.SelectedColumns()) == 0 {
columns := make([]string, 0, len({{ $receiver }}.fields) + len({{ $receiver}}.fns))
for _, f := range {{ $receiver }}.fields {