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

Function ExtractFunctions

pkg/gosqlx/extract.go:369–383  ·  view source on GitHub ↗

ExtractFunctions extracts all function calls from an AST. This function traverses the AST and collects all function names, including: - Aggregate functions (COUNT, SUM, AVG, etc.) - Window functions (ROW_NUMBER, RANK, etc.) - Scalar functions (UPPER, LOWER, NOW, etc.) Returns a deduplicated slice

(astNode *ast.AST)

Source from the content-addressed store, hash-verified

367// functions := gosqlx.ExtractFunctions(ast)
368// // functions = ["COUNT", "UPPER"]
369func ExtractFunctions(astNode *ast.AST) []string {
370 if astNode == nil {
371 return nil
372 }
373
374 collector := &functionCollector{
375 functions: make(map[string]bool),
376 }
377
378 for _, stmt := range astNode.Statements {
379 collector.collectFromNode(stmt)
380 }
381
382 return collector.toSlice()
383}
384
385// tableCollector collects table names from AST nodes
386type tableCollector struct {

Calls 2

collectFromNodeMethod · 0.95
toSliceMethod · 0.95