MCPcopy
hub / github.com/ent/ent / querySpec

Method querySpec

entc/integration/migrate/entv2/customtype_query.go:371–409  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

369}
370
371func (_q *CustomTypeQuery) querySpec() *sqlgraph.QuerySpec {
372 _spec := sqlgraph.NewQuerySpec(customtype.Table, customtype.Columns, sqlgraph.NewFieldSpec(customtype.FieldID, field.TypeInt))
373 _spec.From = _q.sql
374 if unique := _q.ctx.Unique; unique != nil {
375 _spec.Unique = *unique
376 } else if _q.path != nil {
377 _spec.Unique = true
378 }
379 if fields := _q.ctx.Fields; len(fields) > 0 {
380 _spec.Node.Columns = make([]string, 0, len(fields))
381 _spec.Node.Columns = append(_spec.Node.Columns, customtype.FieldID)
382 for i := range fields {
383 if fields[i] != customtype.FieldID {
384 _spec.Node.Columns = append(_spec.Node.Columns, fields[i])
385 }
386 }
387 }
388 if ps := _q.predicates; len(ps) > 0 {
389 _spec.Predicate = func(selector *sql.Selector) {
390 for i := range ps {
391 ps[i](selector)
392 }
393 }
394 }
395 if limit := _q.ctx.Limit; limit != nil {
396 _spec.Limit = *limit
397 }
398 if offset := _q.ctx.Offset; offset != nil {
399 _spec.Offset = *offset
400 }
401 if ps := _q.order; len(ps) > 0 {
402 _spec.Order = func(selector *sql.Selector) {
403 for i := range ps {
404 ps[i](selector)
405 }
406 }
407 }
408 return _spec
409}
410
411func (_q *CustomTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
412 builder := sql.Dialect(_q.driver.Dialect())

Callers 2

sqlAllMethod · 0.95
sqlCountMethod · 0.95

Calls 2

NewQuerySpecFunction · 0.92
NewFieldSpecFunction · 0.92

Tested by

no test coverage detected