MCPcopy
hub / github.com/crowdsecurity/crowdsec / sqlScan

Method sqlScan

pkg/database/ent/meta_query.go:539–564  ·  view source on GitHub ↗
(ctx context.Context, root *MetaQuery, v any)

Source from the content-addressed store, hash-verified

537}
538
539func (_g *MetaGroupBy) sqlScan(ctx context.Context, root *MetaQuery, v any) error {
540 selector := root.sqlQuery(ctx).Select()
541 aggregation := make([]string, 0, len(_g.fns))
542 for _, fn := range _g.fns {
543 aggregation = append(aggregation, fn(selector))
544 }
545 if len(selector.SelectedColumns()) == 0 {
546 columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
547 for _, f := range *_g.flds {
548 columns = append(columns, selector.C(f))
549 }
550 columns = append(columns, aggregation...)
551 selector.Select(columns...)
552 }
553 selector.GroupBy(selector.Columns(*_g.flds...)...)
554 if err := selector.Err(); err != nil {
555 return err
556 }
557 rows := &sql.Rows{}
558 query, args := selector.Query()
559 if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
560 return err
561 }
562 defer rows.Close()
563 return sql.ScanSlice(rows, v)
564}
565
566// MetaSelect is the builder for selecting fields of Meta entities.
567type MetaSelect struct {

Callers

nothing calls this directly

Calls 6

ErrMethod · 0.80
SelectMethod · 0.45
sqlQueryMethod · 0.45
GroupByMethod · 0.45
QueryMethod · 0.45
CloseMethod · 0.45

Tested by

no test coverage detected