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

Method sqlQuery

ent/storagepolicy_query.go:708–738  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

706}
707
708func (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.
741type StoragePolicyGroupBy struct {

Callers 6

QueryGroupsMethod · 0.95
QueryFilesMethod · 0.95
QueryEntitiesMethod · 0.95
QueryNodeMethod · 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