formatAlterStatement formats the generic ALTER statement (from alter.go)
(stmt *ast.AlterStatement)
| 458 | |
| 459 | // formatAlterStatement formats the generic ALTER statement (from alter.go) |
| 460 | func (f *SQLFormatter) formatAlterStatement(stmt *ast.AlterStatement) error { |
| 461 | // Format ALTER TABLE if it's a table alteration |
| 462 | if stmt.Type == ast.AlterTypeTable { |
| 463 | f.writeKeyword("ALTER TABLE") |
| 464 | f.builder.WriteString(" " + stmt.Name) |
| 465 | |
| 466 | // Format the operation if present |
| 467 | if stmt.Operation != nil { |
| 468 | if op, ok := stmt.Operation.(*ast.AlterTableOperation); ok { |
| 469 | f.writeNewline() |
| 470 | f.increaseIndent() |
| 471 | f.builder.WriteString(f.currentIndent()) |
| 472 | f.formatAlterTableOperation(op) |
| 473 | f.decreaseIndent() |
| 474 | } |
| 475 | } |
| 476 | return nil |
| 477 | } |
| 478 | |
| 479 | // For other ALTER types, provide a basic format |
| 480 | f.writeKeyword("ALTER") |
| 481 | switch stmt.Type { |
| 482 | case ast.AlterTypeRole: |
| 483 | f.builder.WriteString(" ") |
| 484 | f.writeKeyword("ROLE") |
| 485 | case ast.AlterTypePolicy: |
| 486 | f.builder.WriteString(" ") |
| 487 | f.writeKeyword("POLICY") |
| 488 | case ast.AlterTypeConnector: |
| 489 | f.builder.WriteString(" ") |
| 490 | f.writeKeyword("CONNECTOR") |
| 491 | } |
| 492 | f.builder.WriteString(" " + stmt.Name) |
| 493 | |
| 494 | return nil |
| 495 | } |
| 496 | |
| 497 | // formatAlterTableOperation formats a single ALTER TABLE operation |
| 498 | func (f *SQLFormatter) formatAlterTableOperation(op *ast.AlterTableOperation) { |
no test coverage detected