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

Method formatSetOperation

cmd/gosqlx/cmd/sql_formatter.go:237–258  ·  view source on GitHub ↗

formatSetOperation formats UNION, EXCEPT, INTERSECT statements

(stmt *ast.SetOperation)

Source from the content-addressed store, hash-verified

235
236// formatSetOperation formats UNION, EXCEPT, INTERSECT statements
237func (f *SQLFormatter) formatSetOperation(stmt *ast.SetOperation) error {
238 // Format left statement
239 if err := f.formatStatement(stmt.Left); err != nil {
240 return fmt.Errorf("failed to format left side of %s: %w", stmt.Operator, err)
241 }
242
243 // Add newline and operator
244 f.writeNewline()
245 f.writeKeyword(stmt.Operator)
246 if stmt.All {
247 f.builder.WriteString(" ")
248 f.writeKeyword("ALL")
249 }
250 f.writeNewline()
251
252 // Format right statement
253 if err := f.formatStatement(stmt.Right); err != nil {
254 return fmt.Errorf("failed to format right side of %s: %w", stmt.Operator, err)
255 }
256
257 return nil
258}
259
260// formatInsert formats INSERT statements
261func (f *SQLFormatter) formatInsert(stmt *ast.InsertStatement) error {

Callers 1

formatStatementMethod · 0.95

Calls 4

formatStatementMethod · 0.95
writeNewlineMethod · 0.95
writeKeywordMethod · 0.95
ErrorfMethod · 0.65

Tested by

no test coverage detected