MCPcopy Create free account
hub / github.com/efectn/go-orm-benchmarks / sqlAll

Method sqlAll

bench/ent/model_query.go:332–355  ·  view source on GitHub ↗
(ctx context.Context, hooks ...queryHook)

Source from the content-addressed store, hash-verified

330}
331
332func (mq *ModelQuery) sqlAll(ctx context.Context, hooks ...queryHook) ([]*Model, error) {
333 var (
334 nodes = []*Model{}
335 _spec = mq.querySpec()
336 )
337 _spec.ScanValues = func(columns []string) ([]any, error) {
338 return (*Model).scanValues(nil, columns)
339 }
340 _spec.Assign = func(columns []string, values []any) error {
341 node := &Model{config: mq.config}
342 nodes = append(nodes, node)
343 return node.assignValues(columns, values)
344 }
345 for i := range hooks {
346 hooks[i](ctx, _spec)
347 }
348 if err := sqlgraph.QueryNodes(ctx, mq.driver, _spec); err != nil {
349 return nil, err
350 }
351 if len(nodes) == 0 {
352 return nodes, nil
353 }
354 return nodes, nil
355}
356
357func (mq *ModelQuery) sqlCount(ctx context.Context) (int, error) {
358 _spec := mq.querySpec()

Callers 1

querierAllFunction · 0.80

Calls 3

querySpecMethod · 0.95
assignValuesMethod · 0.95
scanValuesMethod · 0.80

Tested by

no test coverage detected