MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / sqlScan

Method sqlScan

ent/group_query.go:613–638  ·  view source on GitHub ↗
(ctx context.Context, root *GroupQuery, v any)

Source from the content-addressed store, hash-verified

611}
612
613func (ggb *GroupGroupBy) sqlScan(ctx context.Context, root *GroupQuery, v any) error {
614 selector := root.sqlQuery(ctx).Select()
615 aggregation := make([]string, 0, len(ggb.fns))
616 for _, fn := range ggb.fns {
617 aggregation = append(aggregation, fn(selector))
618 }
619 if len(selector.SelectedColumns()) == 0 {
620 columns := make([]string, 0, len(*ggb.flds)+len(ggb.fns))
621 for _, f := range *ggb.flds {
622 columns = append(columns, selector.C(f))
623 }
624 columns = append(columns, aggregation...)
625 selector.Select(columns...)
626 }
627 selector.GroupBy(selector.Columns(*ggb.flds...)...)
628 if err := selector.Err(); err != nil {
629 return err
630 }
631 rows := &sql.Rows{}
632 query, args := selector.Query()
633 if err := ggb.build.driver.Query(ctx, query, args, rows); err != nil {
634 return err
635 }
636 defer rows.Close()
637 return sql.ScanSlice(rows, v)
638}
639
640// GroupSelect is the builder for selecting fields of Group entities.
641type GroupSelect struct {

Callers

nothing calls this directly

Calls 5

CloseMethod · 0.65
SelectMethod · 0.45
sqlQueryMethod · 0.45
GroupByMethod · 0.45
QueryMethod · 0.45

Tested by

no test coverage detected