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

Method sqlScan

ent/storagepolicy_query.go:809–828  ·  view source on GitHub ↗
(ctx context.Context, root *StoragePolicyQuery, v any)

Source from the content-addressed store, hash-verified

807}
808
809func (sps *StoragePolicySelect) sqlScan(ctx context.Context, root *StoragePolicyQuery, v any) error {
810 selector := root.sqlQuery(ctx)
811 aggregation := make([]string, 0, len(sps.fns))
812 for _, fn := range sps.fns {
813 aggregation = append(aggregation, fn(selector))
814 }
815 switch n := len(*sps.selector.flds); {
816 case n == 0 && len(aggregation) > 0:
817 selector.Select(aggregation...)
818 case n != 0 && len(aggregation) > 0:
819 selector.AppendSelect(aggregation...)
820 }
821 rows := &sql.Rows{}
822 query, args := selector.Query()
823 if err := sps.driver.Query(ctx, query, args, rows); err != nil {
824 return err
825 }
826 defer rows.Close()
827 return sql.ScanSlice(rows, v)
828}

Callers

nothing calls this directly

Calls 4

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

Tested by

no test coverage detected