formatCreateTable formats CREATE TABLE statements
(stmt *ast.CreateTableStatement)
| 357 | |
| 358 | // formatCreateTable formats CREATE TABLE statements |
| 359 | func (f *SQLFormatter) formatCreateTable(stmt *ast.CreateTableStatement) error { |
| 360 | f.writeKeyword("CREATE") |
| 361 | if stmt.Temporary { |
| 362 | f.builder.WriteString(" ") |
| 363 | f.writeKeyword("TEMPORARY") |
| 364 | } |
| 365 | f.builder.WriteString(" ") |
| 366 | f.writeKeyword("TABLE") |
| 367 | |
| 368 | if stmt.IfNotExists { |
| 369 | f.builder.WriteString(" ") |
| 370 | f.writeKeyword("IF NOT EXISTS") |
| 371 | } |
| 372 | |
| 373 | f.builder.WriteString(" " + stmt.Name + " (") |
| 374 | |
| 375 | if !f.compact { |
| 376 | f.writeNewline() |
| 377 | f.increaseIndent() |
| 378 | } |
| 379 | |
| 380 | for i, col := range stmt.Columns { |
| 381 | col := col // G601: Create local copy to avoid memory aliasing |
| 382 | if i > 0 { |
| 383 | f.builder.WriteString(",") |
| 384 | if !f.compact { |
| 385 | f.writeNewline() |
| 386 | } else { |
| 387 | f.builder.WriteString(" ") |
| 388 | } |
| 389 | } |
| 390 | if !f.compact { |
| 391 | f.builder.WriteString(f.currentIndent()) |
| 392 | } |
| 393 | f.formatColumnDef(&col) |
| 394 | } |
| 395 | |
| 396 | if !f.compact { |
| 397 | f.decreaseIndent() |
| 398 | f.writeNewline() |
| 399 | } |
| 400 | f.builder.WriteString(")") |
| 401 | |
| 402 | return nil |
| 403 | } |
| 404 | |
| 405 | // formatCreateIndex formats CREATE INDEX statements |
| 406 | func (f *SQLFormatter) formatCreateIndex(stmt *ast.CreateIndexStatement) error { |
no test coverage detected