| 404 | } |
| 405 | |
| 406 | func (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. |
| 439 | type SettingGroupBy struct { |