(alias string)
| 408 | } |
| 409 | |
| 410 | func (sel *selector) As(alias string) db.Selector { |
| 411 | return sel.frame(func(sq *selectorQuery) error { |
| 412 | if sq.table == nil { |
| 413 | return errors.New("Cannot use As() without a preceding From() expression") |
| 414 | } |
| 415 | last := len(sq.table.Columns) - 1 |
| 416 | if raw, ok := sq.table.Columns[last].(*exql.Raw); ok { |
| 417 | compiled, err := exql.ColumnWithName(alias).Compile(sel.template()) |
| 418 | if err != nil { |
| 419 | return err |
| 420 | } |
| 421 | sq.table.Columns[last] = &exql.Raw{Value: raw.Value + " AS " + compiled} |
| 422 | } |
| 423 | return nil |
| 424 | }) |
| 425 | } |
| 426 | |
| 427 | func (sel *selector) statement() *exql.Statement { |
| 428 | sq, _ := sel.build() |
nothing calls this directly
no test coverage detected