(ctx context.Context)
| 706 | } |
| 707 | |
| 708 | func (spq *StoragePolicyQuery) sqlQuery(ctx context.Context) *sql.Selector { |
| 709 | builder := sql.Dialect(spq.driver.Dialect()) |
| 710 | t1 := builder.Table(storagepolicy.Table) |
| 711 | columns := spq.ctx.Fields |
| 712 | if len(columns) == 0 { |
| 713 | columns = storagepolicy.Columns |
| 714 | } |
| 715 | selector := builder.Select(t1.Columns(columns...)...).From(t1) |
| 716 | if spq.sql != nil { |
| 717 | selector = spq.sql |
| 718 | selector.Select(selector.Columns(columns...)...) |
| 719 | } |
| 720 | if spq.ctx.Unique != nil && *spq.ctx.Unique { |
| 721 | selector.Distinct() |
| 722 | } |
| 723 | for _, p := range spq.predicates { |
| 724 | p(selector) |
| 725 | } |
| 726 | for _, p := range spq.order { |
| 727 | p(selector) |
| 728 | } |
| 729 | if offset := spq.ctx.Offset; offset != nil { |
| 730 | // limit is mandatory for offset clause. We start |
| 731 | // with default value, and override it below if needed. |
| 732 | selector.Offset(*offset).Limit(math.MaxInt32) |
| 733 | } |
| 734 | if limit := spq.ctx.Limit; limit != nil { |
| 735 | selector.Limit(*limit) |
| 736 | } |
| 737 | return selector |
| 738 | } |
| 739 | |
| 740 | // StoragePolicyGroupBy is the group-by builder for StoragePolicy entities. |
| 741 | type StoragePolicyGroupBy struct { |
no test coverage detected