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)
| 234 | // GetColumnNames implements the expander.ColumnGetter interface. |
| 235 | // It prepares a query and returns the column names from the result set description. |
| 236 | func (a *Analyzer) GetColumnNames(ctx context.Context, query string) ([]string, error) { |
| 237 | a.mu.Lock() |
| 238 | defer a.mu.Unlock() |
| 239 | |
| 240 | if a.conn == nil { |
| 241 | return nil, fmt.Errorf("database connection not initialized") |
| 242 | } |
| 243 | |
| 244 | stmt, _, err := a.conn.Prepare(query) |
| 245 | if err != nil { |
| 246 | return nil, err |
| 247 | } |
| 248 | defer stmt.Close() |
| 249 | |
| 250 | colCount := stmt.ColumnCount() |
| 251 | columns := make([]string, colCount) |
| 252 | for i := 0; i < colCount; i++ { |
| 253 | columns[i] = stmt.ColumnName(i) |
| 254 | } |
| 255 | |
| 256 | return columns, nil |
| 257 | } |
| 258 | |
| 259 | // IntrospectSchema queries the database to build a catalog containing |
| 260 | // tables and columns for the database. |
nothing calls this directly
no test coverage detected