| 558 | } |
| 559 | |
| 560 | func (ogq *OAuthGrantQuery) sqlQuery(ctx context.Context) *sql.Selector { |
| 561 | builder := sql.Dialect(ogq.driver.Dialect()) |
| 562 | t1 := builder.Table(oauthgrant.Table) |
| 563 | columns := ogq.ctx.Fields |
| 564 | if len(columns) == 0 { |
| 565 | columns = oauthgrant.Columns |
| 566 | } |
| 567 | selector := builder.Select(t1.Columns(columns...)...).From(t1) |
| 568 | if ogq.sql != nil { |
| 569 | selector = ogq.sql |
| 570 | selector.Select(selector.Columns(columns...)...) |
| 571 | } |
| 572 | if ogq.ctx.Unique != nil && *ogq.ctx.Unique { |
| 573 | selector.Distinct() |
| 574 | } |
| 575 | for _, p := range ogq.predicates { |
| 576 | p(selector) |
| 577 | } |
| 578 | for _, p := range ogq.order { |
| 579 | p(selector) |
| 580 | } |
| 581 | if offset := ogq.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 := ogq.ctx.Limit; limit != nil { |
| 587 | selector.Limit(*limit) |
| 588 | } |
| 589 | return selector |
| 590 | } |
| 591 | |
| 592 | // OAuthGrantGroupBy is the group-by builder for OAuthGrant entities. |
| 593 | type OAuthGrantGroupBy struct { |