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

Method sqlScan

pkg/database/ent/alert_query.go:770–795  ·  view source on GitHub ↗
(ctx context.Context, root *AlertQuery, v any)

Source from the content-addressed store, hash-verified

768}
769
770func (_g *AlertGroupBy) sqlScan(ctx context.Context, root *AlertQuery, v any) error {
771 selector := root.sqlQuery(ctx).Select()
772 aggregation := make([]string, 0, len(_g.fns))
773 for _, fn := range _g.fns {
774 aggregation = append(aggregation, fn(selector))
775 }
776 if len(selector.SelectedColumns()) == 0 {
777 columns := make([]string, 0, len(*_g.flds)+len(_g.fns))
778 for _, f := range *_g.flds {
779 columns = append(columns, selector.C(f))
780 }
781 columns = append(columns, aggregation...)
782 selector.Select(columns...)
783 }
784 selector.GroupBy(selector.Columns(*_g.flds...)...)
785 if err := selector.Err(); err != nil {
786 return err
787 }
788 rows := &sql.Rows{}
789 query, args := selector.Query()
790 if err := _g.build.driver.Query(ctx, query, args, rows); err != nil {
791 return err
792 }
793 defer rows.Close()
794 return sql.ScanSlice(rows, v)
795}
796
797// AlertSelect is the builder for selecting fields of Alert entities.
798type AlertSelect 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