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

Method prepareQuery

pkg/database/ent/alert_query.go:453–477  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

451}
452
453func (_q *AlertQuery) prepareQuery(ctx context.Context) error {
454 for _, inter := range _q.inters {
455 if inter == nil {
456 return fmt.Errorf("ent: uninitialized interceptor (forgotten import ent/runtime?)")
457 }
458 if trv, ok := inter.(Traverser); ok {
459 if err := trv.Traverse(ctx, _q); err != nil {
460 return err
461 }
462 }
463 }
464 for _, f := range _q.ctx.Fields {
465 if !alert.ValidColumn(f) {
466 return &ValidationError{Name: f, err: fmt.Errorf("ent: invalid field %q for query", f)}
467 }
468 }
469 if _q.path != nil {
470 prev, err := _q.path(ctx)
471 if err != nil {
472 return err
473 }
474 _q.sql = prev
475 }
476 return nil
477}
478
479func (_q *AlertQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Alert, error) {
480 var (

Callers 8

QueryOwnerMethod · 0.95
QueryDecisionsMethod · 0.95
QueryEventsMethod · 0.95
QueryMetasMethod · 0.95
AllMethod · 0.95
CountMethod · 0.95
ScanMethod · 0.45
ScanMethod · 0.45

Calls 1

ValidColumnFunction · 0.92

Tested by

no test coverage detected