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

Function FormatStatement

pkg/formatter/render.go:124–171  ·  view source on GitHub ↗

FormatStatement renders a single AST statement with the given options. Returns "" for nil.

(s ast.Statement, opts ast.FormatOptions)

Source from the content-addressed store, hash-verified

122// FormatStatement renders a single AST statement with the given options.
123// Returns "" for nil.
124func FormatStatement(s ast.Statement, opts ast.FormatOptions) string {
125 if s == nil {
126 return ""
127 }
128 switch v := s.(type) {
129 case *ast.SelectStatement:
130 return renderSelect(v, opts)
131 case *ast.InsertStatement:
132 return renderInsert(v, opts)
133 case *ast.UpdateStatement:
134 return renderUpdate(v, opts)
135 case *ast.DeleteStatement:
136 return renderDelete(v, opts)
137 case *ast.CreateTableStatement:
138 return renderCreateTable(v, opts)
139 case *ast.SetOperation:
140 return renderSetOperation(v, opts)
141 case *ast.AlterTableStatement: //nolint:staticcheck // AlterTableStatement kept for backward compatibility
142 return renderAlterTable(v, opts)
143 case *ast.CreateIndexStatement:
144 return renderCreateIndex(v, opts)
145 case *ast.CreateViewStatement:
146 return renderCreateView(v, opts)
147 case *ast.CreateMaterializedViewStatement:
148 return renderCreateMaterializedView(v, opts)
149 case *ast.RefreshMaterializedViewStatement:
150 return renderRefreshMaterializedView(v, opts)
151 case *ast.DropStatement:
152 return renderDrop(v, opts)
153 case *ast.TruncateStatement:
154 return renderTruncate(v, opts)
155 case *ast.MergeStatement:
156 return renderMerge(v, opts)
157 case *ast.CreateSequenceStatement:
158 return renderCreateSequence(v, opts)
159 case *ast.AlterSequenceStatement:
160 return renderAlterSequence(v, opts)
161 case *ast.DropSequenceStatement:
162 return renderDropSequence(v, opts)
163 case *ast.ShowStatement:
164 return renderShow(v, opts)
165 case *ast.DescribeStatement:
166 return renderDescribe(v, opts)
167 default:
168 // Fallback to SQL() for unrecognized statement types
169 return stmtSQL(s)
170 }
171}
172
173// FormatExpression renders an AST expression with the given options.
174// Returns "" for nil.

Callers 15

TranspileFunction · 0.92
NormalizeFunction · 0.92
FormatSQLFunction · 0.92
FormatSQLWithDialectFunction · 0.92
fmtStmtFunction · 0.92
TestFormat_AlterSequenceFunction · 0.92
TestFormat_DropSequenceFunction · 0.92
TestFormat_ShowStatementFunction · 0.92

Calls 15

renderSelectFunction · 0.85
renderInsertFunction · 0.85
renderUpdateFunction · 0.85
renderDeleteFunction · 0.85
renderCreateTableFunction · 0.85
renderSetOperationFunction · 0.85
renderAlterTableFunction · 0.85
renderCreateIndexFunction · 0.85
renderCreateViewFunction · 0.85
renderDropFunction · 0.85