(ctx context.Context)
| 558 | } |
| 559 | |
| 560 | func (gq *GroupQuery) sqlQuery(ctx context.Context) *sql.Selector { |
| 561 | builder := sql.Dialect(gq.driver.Dialect()) |
| 562 | t1 := builder.Table(group.Table) |
| 563 | columns := gq.ctx.Fields |
| 564 | if len(columns) == 0 { |
| 565 | columns = group.Columns |
| 566 | } |
| 567 | selector := builder.Select(t1.Columns(columns...)...).From(t1) |
| 568 | if gq.sql != nil { |
| 569 | selector = gq.sql |
| 570 | selector.Select(selector.Columns(columns...)...) |
| 571 | } |
| 572 | if gq.ctx.Unique != nil && *gq.ctx.Unique { |
| 573 | selector.Distinct() |
| 574 | } |
| 575 | for _, p := range gq.predicates { |
| 576 | p(selector) |
| 577 | } |
| 578 | for _, p := range gq.order { |
| 579 | p(selector) |
| 580 | } |
| 581 | if offset := gq.ctx.Offset; offset != nil { |
| 582 | // limit is mandatory for offset clause. We start |
| 583 | // with default value, and override it below if needed. |
| 584 | selector.Offset(*offset).Limit(math.MaxInt32) |
| 585 | } |
| 586 | if limit := gq.ctx.Limit; limit != nil { |
| 587 | selector.Limit(*limit) |
| 588 | } |
| 589 | return selector |
| 590 | } |
| 591 | |
| 592 | // GroupGroupBy is the group-by builder for Group entities. |
| 593 | type GroupGroupBy struct { |
no test coverage detected