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

Method sqlQuery

entc/integration/multischema/versioned/user_query.go:1016–1052  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1014}
1015
1016func (_q *UserQuery) sqlQuery(ctx context.Context) *sql.Selector {
1017 builder := sql.Dialect(_q.driver.Dialect())
1018 t1 := builder.Table(user.Table)
1019 columns := _q.ctx.Fields
1020 if len(columns) == 0 {
1021 columns = user.Columns
1022 }
1023 selector := builder.Select(t1.Columns(columns...)...).From(t1)
1024 if _q.sql != nil {
1025 selector = _q.sql
1026 selector.Select(selector.Columns(columns...)...)
1027 }
1028 if _q.ctx.Unique != nil && *_q.ctx.Unique {
1029 selector.Distinct()
1030 }
1031 t1.Schema(_q.schemaConfig.User)
1032 ctx = internal.NewSchemaConfigContext(ctx, _q.schemaConfig)
1033 selector.WithContext(ctx)
1034 for _, m := range _q.modifiers {
1035 m(selector)
1036 }
1037 for _, p := range _q.predicates {
1038 p(selector)
1039 }
1040 for _, p := range _q.order {
1041 p(selector)
1042 }
1043 if offset := _q.ctx.Offset; offset != nil {
1044 // limit is mandatory for offset clause. We start
1045 // with default value, and override it below if needed.
1046 selector.Offset(*offset).Limit(math.MaxInt32)
1047 }
1048 if limit := _q.ctx.Limit; limit != nil {
1049 selector.Limit(*limit)
1050 }
1051 return selector
1052}
1053
1054// Modify adds a query modifier for attaching custom logic to queries.
1055func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect {

Callers 8

QueryPetsMethod · 0.95
QueryGroupsMethod · 0.95
QueryFriendsMethod · 0.95
QueryFollowersMethod · 0.95
QueryFollowingMethod · 0.95
QueryFriendshipsMethod · 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