MCPcopy
hub / github.com/ent/ent / sqlQuery

Method sqlQuery

entc/integration/migrate/entv2/customtype_query.go:411–441  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

409}
410
411func (_q *CustomTypeQuery) sqlQuery(ctx context.Context) *sql.Selector {
412 builder := sql.Dialect(_q.driver.Dialect())
413 t1 := builder.Table(customtype.Table)
414 columns := _q.ctx.Fields
415 if len(columns) == 0 {
416 columns = customtype.Columns
417 }
418 selector := builder.Select(t1.Columns(columns...)...).From(t1)
419 if _q.sql != nil {
420 selector = _q.sql
421 selector.Select(selector.Columns(columns...)...)
422 }
423 if _q.ctx.Unique != nil && *_q.ctx.Unique {
424 selector.Distinct()
425 }
426 for _, p := range _q.predicates {
427 p(selector)
428 }
429 for _, p := range _q.order {
430 p(selector)
431 }
432 if offset := _q.ctx.Offset; offset != nil {
433 // limit is mandatory for offset clause. We start
434 // with default value, and override it below if needed.
435 selector.Offset(*offset).Limit(math.MaxInt32)
436 }
437 if limit := _q.ctx.Limit; limit != nil {
438 selector.Limit(*limit)
439 }
440 return selector
441}
442
443// CustomTypeGroupBy is the group-by builder for CustomType entities.
444type CustomTypeGroupBy struct {

Callers 2

sqlScanMethod · 0.45
sqlScanMethod · 0.45

Calls 9

DialectFunction · 0.92
DistinctMethod · 0.80
DialectMethod · 0.65
ColumnsMethod · 0.65
LimitMethod · 0.65
OffsetMethod · 0.65
TableMethod · 0.45
FromMethod · 0.45
SelectMethod · 0.45

Tested by

no test coverage detected