MCPcopy Create free account
hub / github.com/cloudreve/cloudreve / sqlQuery

Method sqlQuery

ent/file_query.go:1036–1066  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

1034}
1035
1036func (fq *FileQuery) sqlQuery(ctx context.Context) *sql.Selector {
1037 builder := sql.Dialect(fq.driver.Dialect())
1038 t1 := builder.Table(file.Table)
1039 columns := fq.ctx.Fields
1040 if len(columns) == 0 {
1041 columns = file.Columns
1042 }
1043 selector := builder.Select(t1.Columns(columns...)...).From(t1)
1044 if fq.sql != nil {
1045 selector = fq.sql
1046 selector.Select(selector.Columns(columns...)...)
1047 }
1048 if fq.ctx.Unique != nil && *fq.ctx.Unique {
1049 selector.Distinct()
1050 }
1051 for _, p := range fq.predicates {
1052 p(selector)
1053 }
1054 for _, p := range fq.order {
1055 p(selector)
1056 }
1057 if offset := fq.ctx.Offset; offset != nil {
1058 // limit is mandatory for offset clause. We start
1059 // with default value, and override it below if needed.
1060 selector.Offset(*offset).Limit(math.MaxInt32)
1061 }
1062 if limit := fq.ctx.Limit; limit != nil {
1063 selector.Limit(*limit)
1064 }
1065 return selector
1066}
1067
1068// FileGroupBy is the group-by builder for File entities.
1069type FileGroupBy struct {

Callers 10

QueryOwnerMethod · 0.95
QueryStoragePoliciesMethod · 0.95
QueryParentMethod · 0.95
QueryChildrenMethod · 0.95
QueryMetadataMethod · 0.95
QueryEntitiesMethod · 0.95
QuerySharesMethod · 0.95
QueryDirectLinksMethod · 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