formatCreateIndex formats CREATE INDEX statements
(stmt *ast.CreateIndexStatement)
| 404 | |
| 405 | // formatCreateIndex formats CREATE INDEX statements |
| 406 | func (f *SQLFormatter) formatCreateIndex(stmt *ast.CreateIndexStatement) error { |
| 407 | f.writeKeyword("CREATE") |
| 408 | if stmt.Unique { |
| 409 | f.builder.WriteString(" ") |
| 410 | f.writeKeyword("UNIQUE") |
| 411 | } |
| 412 | f.builder.WriteString(" ") |
| 413 | f.writeKeyword("INDEX") |
| 414 | |
| 415 | if stmt.IfNotExists { |
| 416 | f.builder.WriteString(" ") |
| 417 | f.writeKeyword("IF NOT EXISTS") |
| 418 | } |
| 419 | |
| 420 | f.builder.WriteString(" " + stmt.Name) |
| 421 | f.builder.WriteString(" ") |
| 422 | f.writeKeyword("ON") |
| 423 | f.builder.WriteString(" " + stmt.Table + " (") |
| 424 | |
| 425 | for i, col := range stmt.Columns { |
| 426 | if i > 0 { |
| 427 | f.builder.WriteString(", ") |
| 428 | } |
| 429 | f.builder.WriteString(col.Column) |
| 430 | if col.Direction != "" { |
| 431 | f.builder.WriteString(" " + col.Direction) |
| 432 | } |
| 433 | } |
| 434 | f.builder.WriteString(")") |
| 435 | |
| 436 | return nil |
| 437 | } |
| 438 | |
| 439 | // formatAlterTable formats ALTER TABLE statements |
| 440 | func (f *SQLFormatter) formatAlterTable(stmt *ast.AlterTableStatement) error { //nolint:staticcheck // AlterTableStatement kept for backward compatibility |
no test coverage detected