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

Method formatAlterTable

cmd/gosqlx/cmd/sql_formatter.go:440–457  ·  view source on GitHub ↗

formatAlterTable formats ALTER TABLE statements

(stmt *ast.AlterTableStatement)

Source from the content-addressed store, hash-verified

438
439// formatAlterTable formats ALTER TABLE statements
440func (f *SQLFormatter) formatAlterTable(stmt *ast.AlterTableStatement) error { //nolint:staticcheck // AlterTableStatement kept for backward compatibility
441 f.writeKeyword("ALTER TABLE")
442 f.builder.WriteString(" " + stmt.Table)
443
444 for i, action := range stmt.Actions {
445 action := action // G601: Create local copy to avoid memory aliasing
446 if i > 0 {
447 f.builder.WriteString(",")
448 }
449 f.writeNewline()
450 f.increaseIndent()
451 f.builder.WriteString(f.currentIndent())
452 f.formatAlterTableAction(&action)
453 f.decreaseIndent()
454 }
455
456 return nil
457}
458
459// formatAlterStatement formats the generic ALTER statement (from alter.go)
460func (f *SQLFormatter) formatAlterStatement(stmt *ast.AlterStatement) error {

Callers 1

formatStatementMethod · 0.95

Calls 6

writeKeywordMethod · 0.95
writeNewlineMethod · 0.95
increaseIndentMethod · 0.95
currentIndentMethod · 0.95
decreaseIndentMethod · 0.95

Tested by

no test coverage detected