MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / ExtractColumns

Function ExtractColumns

pkg/gosqlx/extract.go:302–316  ·  view source on GitHub ↗

ExtractColumns extracts all column references from an AST. This function traverses the AST and collects column references from: - SELECT lists - WHERE conditions - GROUP BY clauses - ORDER BY clauses - JOIN conditions - HAVING clauses Returns a deduplicated slice of column names (without table qua

(astNode *ast.AST)

Source from the content-addressed store, hash-verified

300// columns := gosqlx.ExtractColumns(ast)
301// // columns = ["name", "email", "active", "created_at"]
302func ExtractColumns(astNode *ast.AST) []string {
303 if astNode == nil {
304 return nil
305 }
306
307 collector := &columnCollector{
308 columns: make(map[string]bool),
309 }
310
311 for _, stmt := range astNode.Statements {
312 collector.collectFromNode(stmt)
313 }
314
315 return collector.toSlice()
316}
317
318// ExtractColumnsQualified extracts all column references with their table qualifiers.
319//

Callers 15

ExampleExtractColumnsFunction · 0.92
Example_extractColumnsFunction · 0.92
TestExtractColumnsFunction · 0.92
gosqlx_extract_columnsFunction · 0.92
afterStatementMethod · 0.92
InstrumentedParseFunction · 0.92
ExtractMetadataFunction · 0.85
TestExtractEdgeCasesFunction · 0.85

Calls 2

collectFromNodeMethod · 0.95
toSliceMethod · 0.95