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

Method AnalyzeSQL

pkg/advisor/optimizer.go:180–187  ·  view source on GitHub ↗

AnalyzeSQL is a convenience method that parses the SQL string and analyzes it. This method uses gosqlx.Parse internally for tokenization and parsing. If parsing fails, the error is returned and no analysis is performed.

(sql string)

Source from the content-addressed store, hash-verified

178// This method uses gosqlx.Parse internally for tokenization and parsing.
179// If parsing fails, the error is returned and no analysis is performed.
180func (o *Optimizer) AnalyzeSQL(sql string) (*OptimizationResult, error) {
181 tree, err := gosqlx.Parse(sql)
182 if err != nil {
183 return nil, fmt.Errorf("failed to parse SQL: %w", err)
184 }
185
186 return o.Analyze(tree), nil
187}
188
189// classifyComplexity determines query complexity based on AST characteristics.
190func classifyComplexity(tree *ast.AST) string {

Callers 6

analyzeFunction · 0.80
mustAnalyzeFunction · 0.80
TestAnalyzeSQLFunction · 0.80
doOptimizeFunction · 0.80

Calls 3

AnalyzeMethod · 0.95
ParseFunction · 0.92
ErrorfMethod · 0.65

Tested by 4

mustAnalyzeFunction · 0.64
TestAnalyzeSQLFunction · 0.64