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

Method analyzeInsertStatement

cmd/gosqlx/cmd/sql_analyzer.go:190–204  ·  view source on GitHub ↗

analyzeInsertStatement analyzes INSERT statements

(stmt *ast.InsertStatement)

Source from the content-addressed store, hash-verified

188
189// analyzeInsertStatement analyzes INSERT statements
190func (a *SQLAnalyzer) analyzeInsertStatement(stmt *ast.InsertStatement) {
191 // Check for INSERT without explicit columns
192 if len(stmt.Columns) == 0 && len(stmt.Values) > 0 {
193 a.addSecurityIssue("INSERT_WITHOUT_COLUMNS", "MEDIUM",
194 "INSERT without explicit columns is brittle and error-prone",
195 "Always specify column names in INSERT statements")
196 }
197
198 // Check for bulk operations without transaction
199 if len(stmt.Values) > 100 {
200 a.addPerformanceIssue("BULK_INSERT", "LOW",
201 "Large INSERT operations should use batch processing",
202 "performance", "Consider using batch INSERT or COPY operations")
203 }
204}
205
206// analyzeUpdateStatement analyzes UPDATE statements
207func (a *SQLAnalyzer) analyzeUpdateStatement(stmt *ast.UpdateStatement) {

Callers 1

VisitMethod · 0.95

Calls 2

addSecurityIssueMethod · 0.95
addPerformanceIssueMethod · 0.95

Tested by

no test coverage detected