GetColumnNames implements the expander.ColumnGetter interface. It prepares a query and returns the column names from the result set description.
(ctx context.Context, query string)
| 523 | // GetColumnNames implements the expander.ColumnGetter interface. |
| 524 | // It prepares a query and returns the column names from the result set description. |
| 525 | func (a *Analyzer) GetColumnNames(ctx context.Context, query string) ([]string, error) { |
| 526 | if a.pool == nil { |
| 527 | return nil, fmt.Errorf("database connection not initialized") |
| 528 | } |
| 529 | |
| 530 | conn, err := a.pool.Acquire(ctx) |
| 531 | if err != nil { |
| 532 | return nil, err |
| 533 | } |
| 534 | defer conn.Release() |
| 535 | |
| 536 | desc, err := conn.Conn().Prepare(ctx, "", query) |
| 537 | if err != nil { |
| 538 | return nil, err |
| 539 | } |
| 540 | |
| 541 | columns := make([]string, len(desc.Fields)) |
| 542 | for i, field := range desc.Fields { |
| 543 | columns[i] = field.Name |
| 544 | } |
| 545 | |
| 546 | return columns, nil |
| 547 | } |
nothing calls this directly
no test coverage detected