(ctx context.Context, hooks ...queryHook)
| 368 | } |
| 369 | |
| 370 | func (_q *MachineQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Machine, error) { |
| 371 | var ( |
| 372 | nodes = []*Machine{} |
| 373 | _spec = _q.querySpec() |
| 374 | loadedTypes = [1]bool{ |
| 375 | _q.withAlerts != nil, |
| 376 | } |
| 377 | ) |
| 378 | _spec.ScanValues = func(columns []string) ([]any, error) { |
| 379 | return (*Machine).scanValues(nil, columns) |
| 380 | } |
| 381 | _spec.Assign = func(columns []string, values []any) error { |
| 382 | node := &Machine{config: _q.config} |
| 383 | nodes = append(nodes, node) |
| 384 | node.Edges.loadedTypes = loadedTypes |
| 385 | return node.assignValues(columns, values) |
| 386 | } |
| 387 | for i := range hooks { |
| 388 | hooks[i](ctx, _spec) |
| 389 | } |
| 390 | if err := sqlgraph.QueryNodes(ctx, _q.driver, _spec); err != nil { |
| 391 | return nil, err |
| 392 | } |
| 393 | if len(nodes) == 0 { |
| 394 | return nodes, nil |
| 395 | } |
| 396 | if query := _q.withAlerts; query != nil { |
| 397 | if err := _q.loadAlerts(ctx, query, nodes, |
| 398 | func(n *Machine) { n.Edges.Alerts = []*Alert{} }, |
| 399 | func(n *Machine, e *Alert) { n.Edges.Alerts = append(n.Edges.Alerts, e) }); err != nil { |
| 400 | return nil, err |
| 401 | } |
| 402 | } |
| 403 | return nodes, nil |
| 404 | } |
| 405 | |
| 406 | func (_q *MachineQuery) loadAlerts(ctx context.Context, query *AlertQuery, nodes []*Machine, init func(*Machine), assign func(*Machine, *Alert)) error { |
| 407 | fks := make([]driver.Value, 0, len(nodes)) |
nothing calls this directly
no test coverage detected