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)
| 178 | // This method uses gosqlx.Parse internally for tokenization and parsing. |
| 179 | // If parsing fails, the error is returned and no analysis is performed. |
| 180 | func (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. |
| 190 | func classifyComplexity(tree *ast.AST) string { |