(ctx context.Context)
| 1014 | } |
| 1015 | |
| 1016 | func (_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. |
| 1055 | func (_q *UserQuery) Modify(modifiers ...func(s *sql.Selector)) *UserSelect { |
no test coverage detected