(c *ast.CreateTableStatement, opts ast.FormatOptions)
| 550 | } |
| 551 | |
| 552 | func renderCreateTable(c *ast.CreateTableStatement, opts ast.FormatOptions) string { |
| 553 | if c == nil { |
| 554 | return "" |
| 555 | } |
| 556 | f := newNodeFormatter(opts) |
| 557 | sb := f.sb |
| 558 | |
| 559 | sb.WriteString(f.kw("CREATE")) |
| 560 | sb.WriteString(" ") |
| 561 | if c.Temporary { |
| 562 | sb.WriteString(f.kw("TEMPORARY")) |
| 563 | sb.WriteString(" ") |
| 564 | } |
| 565 | sb.WriteString(f.kw("TABLE")) |
| 566 | sb.WriteString(" ") |
| 567 | if c.IfNotExists { |
| 568 | sb.WriteString(f.kw("IF NOT EXISTS")) |
| 569 | sb.WriteString(" ") |
| 570 | } |
| 571 | sb.WriteString(c.Name) |
| 572 | |
| 573 | if opts.NewlinePerClause { |
| 574 | sb.WriteString(" (\n") |
| 575 | f.depth++ |
| 576 | parts := make([]string, 0, len(c.Columns)+len(c.Constraints)) |
| 577 | for _, col := range c.Columns { |
| 578 | col := col |
| 579 | parts = append(parts, f.indentStr()+columnDefSQL(&col)) |
| 580 | } |
| 581 | for _, con := range c.Constraints { |
| 582 | con := con |
| 583 | parts = append(parts, f.indentStr()+tableConstraintSQL(&con)) |
| 584 | } |
| 585 | sb.WriteString(strings.Join(parts, ",\n")) |
| 586 | f.depth-- |
| 587 | sb.WriteString("\n") |
| 588 | sb.WriteString(f.indentStr()) |
| 589 | sb.WriteString(")") |
| 590 | } else { |
| 591 | sb.WriteString(" (") |
| 592 | parts := make([]string, 0, len(c.Columns)+len(c.Constraints)) |
| 593 | for _, col := range c.Columns { |
| 594 | col := col |
| 595 | parts = append(parts, columnDefSQL(&col)) |
| 596 | } |
| 597 | for _, con := range c.Constraints { |
| 598 | con := con |
| 599 | parts = append(parts, tableConstraintSQL(&con)) |
| 600 | } |
| 601 | sb.WriteString(strings.Join(parts, ", ")) |
| 602 | sb.WriteString(")") |
| 603 | } |
| 604 | |
| 605 | if len(c.Inherits) > 0 { |
| 606 | sb.WriteString(" ") |
| 607 | sb.WriteString(f.kw("INHERITS")) |
| 608 | sb.WriteString(" (") |
| 609 | sb.WriteString(strings.Join(c.Inherits, ", ")) |
no test coverage detected