MCPcopy
hub / github.com/cloudreve/cloudreve / sqlQuery

Method sqlQuery

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

Source from the content-addressed store, hash-verified

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

Callers 4

QueryUserMethod · 0.95
QueryClientMethod · 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