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

Method formatStatement

cmd/gosqlx/cmd/sql_formatter.go:82–115  ·  view source on GitHub ↗

formatStatement formats individual SQL statements

(stmt ast.Statement)

Source from the content-addressed store, hash-verified

80
81// formatStatement formats individual SQL statements
82func (f *SQLFormatter) formatStatement(stmt ast.Statement) error {
83 switch s := stmt.(type) {
84 case *ast.SelectStatement:
85 return f.formatSelect(s)
86 case *ast.InsertStatement:
87 return f.formatInsert(s)
88 case *ast.UpdateStatement:
89 return f.formatUpdate(s)
90 case *ast.DeleteStatement:
91 return f.formatDelete(s)
92 case *ast.CreateTableStatement:
93 return f.formatCreateTable(s)
94 case *ast.CreateIndexStatement:
95 return f.formatCreateIndex(s)
96 case *ast.AlterTableStatement: //nolint:staticcheck // AlterTableStatement kept for backward compatibility
97 return f.formatAlterTable(s)
98 case *ast.AlterStatement:
99 return f.formatAlterStatement(s)
100 case *ast.DropStatement:
101 return f.formatDrop(s)
102 case *ast.CreateViewStatement:
103 return f.formatCreateView(s)
104 case *ast.CreateMaterializedViewStatement:
105 return f.formatCreateMaterializedView(s)
106 case *ast.RefreshMaterializedViewStatement:
107 return f.formatRefreshMaterializedView(s)
108 case *ast.SetOperation:
109 return f.formatSetOperation(s)
110 case *ast.MergeStatement:
111 return f.formatMergeStatement(s)
112 default:
113 return fmt.Errorf("unsupported statement type: %T", stmt)
114 }
115}
116
117// formatSelect formats SELECT statements with proper indentation and alignment
118func (f *SQLFormatter) formatSelect(stmt *ast.SelectStatement) error {

Callers 5

FormatMethod · 0.95
formatSetOperationMethod · 0.95
formatWithClauseMethod · 0.95
formatCreateViewMethod · 0.95

Calls 15

formatSelectMethod · 0.95
formatInsertMethod · 0.95
formatUpdateMethod · 0.95
formatDeleteMethod · 0.95
formatCreateTableMethod · 0.95
formatCreateIndexMethod · 0.95
formatAlterTableMethod · 0.95
formatAlterStatementMethod · 0.95
formatDropMethod · 0.95
formatCreateViewMethod · 0.95

Tested by

no test coverage detected