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

Method sqlQuery

ent/setting_query.go:406–436  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

404}
405
406func (sq *SettingQuery) sqlQuery(ctx context.Context) *sql.Selector {
407 builder := sql.Dialect(sq.driver.Dialect())
408 t1 := builder.Table(setting.Table)
409 columns := sq.ctx.Fields
410 if len(columns) == 0 {
411 columns = setting.Columns
412 }
413 selector := builder.Select(t1.Columns(columns...)...).From(t1)
414 if sq.sql != nil {
415 selector = sq.sql
416 selector.Select(selector.Columns(columns...)...)
417 }
418 if sq.ctx.Unique != nil && *sq.ctx.Unique {
419 selector.Distinct()
420 }
421 for _, p := range sq.predicates {
422 p(selector)
423 }
424 for _, p := range sq.order {
425 p(selector)
426 }
427 if offset := sq.ctx.Offset; offset != nil {
428 // limit is mandatory for offset clause. We start
429 // with default value, and override it below if needed.
430 selector.Offset(*offset).Limit(math.MaxInt32)
431 }
432 if limit := sq.ctx.Limit; limit != nil {
433 selector.Limit(*limit)
434 }
435 return selector
436}
437
438// SettingGroupBy is the group-by builder for Setting entities.
439type SettingGroupBy struct {

Callers 2

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