MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / sqlScan

Method sqlScan

ent/entity_query.go:719–744  ·  view source on GitHub ↗
(ctx context.Context, root *EntityQuery, v any)

Source from the content-addressed store, hash-verified

717}
718
719func (egb *EntityGroupBy) sqlScan(ctx context.Context, root *EntityQuery, v any) error {
720 selector := root.sqlQuery(ctx).Select()
721 aggregation := make([]string, 0, len(egb.fns))
722 for _, fn := range egb.fns {
723 aggregation = append(aggregation, fn(selector))
724 }
725 if len(selector.SelectedColumns()) == 0 {
726 columns := make([]string, 0, len(*egb.flds)+len(egb.fns))
727 for _, f := range *egb.flds {
728 columns = append(columns, selector.C(f))
729 }
730 columns = append(columns, aggregation...)
731 selector.Select(columns...)
732 }
733 selector.GroupBy(selector.Columns(*egb.flds...)...)
734 if err := selector.Err(); err != nil {
735 return err
736 }
737 rows := &sql.Rows{}
738 query, args := selector.Query()
739 if err := egb.build.driver.Query(ctx, query, args, rows); err != nil {
740 return err
741 }
742 defer rows.Close()
743 return sql.ScanSlice(rows, v)
744}
745
746// EntitySelect is the builder for selecting fields of Entity entities.
747type EntitySelect 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