MCPcopy Index your code
hub / github.com/cloudreve/cloudreve / sqlQuery

Method sqlQuery

ent/group_query.go:560–590  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

558}
559
560func (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.
593type GroupGroupBy struct {

Callers 4

QueryUsersMethod · 0.95
QueryStoragePoliciesMethod · 0.95
sqlScanMethod · 0.45
sqlScanMethod · 0.45

Calls 5

pFunction · 0.85
DialectMethod · 0.80
LimitMethod · 0.65
OffsetMethod · 0.65
SelectMethod · 0.45

Tested by

no test coverage detected