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

Method sqlQuery

entc/integration/multischema/ent/user_query.go:1093–1129  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1091}
1092
1093func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
1094 builder := sql.Dialect(_q.driver.Dialect())
1095 t1 := builder.Table(user.Table)
1096 columns := _q.ctx.Fields
1097 if len(columns) == 0 {
1098 columns = user.Columns
1099 }
1100 selector := builder.Select(t1.Columns(columns...)...).From(t1)
1101 if _q.sql != nil {
1102 selector = _q.sql
1103 selector.Select(selector.Columns(columns...)...)
1104 }
1105 if _q.ctx.Unique != nil && *_q.ctx.Unique {
1106 selector.Distinct()
1107 }
1108 t1.Schema(_q.schemaConfig.User)
1109 ctx = internal.NewSchemaConfigContext(ctx, _q.schemaConfig)
1110 selector.WithContext(ctx)
1111 for _, m := range _q.modifiers {
1112 m(selector)
1113 }
1114 for _, p := range _q.predicates {
1115 p(selector)
1116 }
1117 for _, p := range _q.order {
1118 p(selector)
1119 }
1120 if offset := _q.ctx.Offset; offset != nil {
1121 // limit is mandatory for offset clause. We start
1122 // with default value, and override it below if needed.
1123 selector.Offset(*offset).Limit(math.MaxInt32)
1124 }
1125 if limit := _q.ctx.Limit; limit != nil {
1126 selector.Limit(*limit)
1127 }
1128 return selector
1129}
1130
1131// Modify adds a query modifier for attaching custom logic to queries.
1132func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect {

Callers 9

QueryPetsMethod · 0.95
QueryGroupsMethod · 0.95
QueryFriendsMethod · 0.95
QueryParentsMethod · 0.95
QueryChildrenMethod · 0.95
QueryFriendshipsMethod · 0.95
QueryParentHoodMethod · 0.95
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