MCPcopy Create free account
hub / github.com/crowdsecurity/crowdsec / sqlScan

Method sqlScan

pkg/database/ent/machine_query.go:540–565  ·  view source on GitHub ↗
(ctx context.Context, root *MachineQuery, v any)

Source from the content-addressed store, hash-verified

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