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

Method sqlQuery

entc/integration/multischema/ent/cleanuser_query.go:348–384  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

346}
347
348func (_q *CleanUserQuery) sqlQuery(ctx context.Context) *sql.Selector {
349 builder := sql.Dialect(_q.driver.Dialect())
350 t1 := builder.Table(cleanuser.Table)
351 columns := _q.ctx.Fields
352 if len(columns) == 0 {
353 columns = cleanuser.Columns
354 }
355 selector := builder.Select(t1.Columns(columns...)...).From(t1)
356 if _q.sql != nil {
357 selector = _q.sql
358 selector.Select(selector.Columns(columns...)...)
359 }
360 if _q.ctx.Unique != nil && *_q.ctx.Unique {
361 selector.Distinct()
362 }
363 t1.Schema(_q.schemaConfig.CleanUser)
364 ctx = internal.NewSchemaConfigContext(ctx, _q.schemaConfig)
365 selector.WithContext(ctx)
366 for _, m := range _q.modifiers {
367 m(selector)
368 }
369 for _, p := range _q.predicates {
370 p(selector)
371 }
372 for _, p := range _q.order {
373 p(selector)
374 }
375 if offset := _q.ctx.Offset; offset != nil {
376 // limit is mandatory for offset clause. We start
377 // with default value, and override it below if needed.
378 selector.Offset(*offset).Limit(math.MaxInt32)
379 }
380 if limit := _q.ctx.Limit; limit != nil {
381 selector.Limit(*limit)
382 }
383 return selector
384}
385
386// Modify adds a query modifier for attaching custom logic to queries.
387func (_q *CleanUserQuery) Modify(modifiers ...func(s *sql.Selector)) *CleanUserSelect {

Callers 2

sqlScanMethod · 0.45
sqlScanMethod · 0.45

Calls 12

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

Tested by

no test coverage detected