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

Method sqlScan

ent/share_query.go:621–646  ·  view source on GitHub ↗
(ctx context.Context, root *ShareQuery, v any)

Source from the content-addressed store, hash-verified

619}
620
621func (sgb *ShareGroupBy) sqlScan(ctx context.Context, root *ShareQuery, v any) error {
622 selector := root.sqlQuery(ctx).Select()
623 aggregation := make([]string, 0, len(sgb.fns))
624 for _, fn := range sgb.fns {
625 aggregation = append(aggregation, fn(selector))
626 }
627 if len(selector.SelectedColumns()) == 0 {
628 columns := make([]string, 0, len(*sgb.flds)+len(sgb.fns))
629 for _, f := range *sgb.flds {
630 columns = append(columns, selector.C(f))
631 }
632 columns = append(columns, aggregation...)
633 selector.Select(columns...)
634 }
635 selector.GroupBy(selector.Columns(*sgb.flds...)...)
636 if err := selector.Err(); err != nil {
637 return err
638 }
639 rows := &sql.Rows{}
640 query, args := selector.Query()
641 if err := sgb.build.driver.Query(ctx, query, args, rows); err != nil {
642 return err
643 }
644 defer rows.Close()
645 return sql.ScanSlice(rows, v)
646}
647
648// ShareSelect is the builder for selecting fields of Share entities.
649type ShareSelect 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