| 1481 | } |
| 1482 | |
| 1483 | func (node *CreateIndex) doc(p *PrettyCfg) pretty.Doc { |
| 1484 | // Final layout: |
| 1485 | // CREATE [UNIQUE] [INVERTED] INDEX [name] |
| 1486 | // ON tbl (cols...) |
| 1487 | // [STORING ( ... )] |
| 1488 | // [INTERLEAVE ...] |
| 1489 | // [PARTITION BY ...] |
| 1490 | // |
| 1491 | title := make([]pretty.Doc, 0, 6) |
| 1492 | title = append(title, pretty.Keyword("CREATE")) |
| 1493 | if node.Unique { |
| 1494 | title = append(title, pretty.Keyword("UNIQUE")) |
| 1495 | } |
| 1496 | if node.Inverted { |
| 1497 | title = append(title, pretty.Keyword("INVERTED")) |
| 1498 | } |
| 1499 | title = append(title, pretty.Keyword("INDEX")) |
| 1500 | if node.Concurrently { |
| 1501 | title = append(title, pretty.Keyword("CONCURRENTLY")) |
| 1502 | } |
| 1503 | if node.IfNotExists { |
| 1504 | title = append(title, pretty.Keyword("IF NOT EXISTS")) |
| 1505 | } |
| 1506 | if node.Name != "" { |
| 1507 | title = append(title, p.Doc(&node.Name)) |
| 1508 | } |
| 1509 | |
| 1510 | clauses := make([]pretty.Doc, 0, 5) |
| 1511 | clauses = append(clauses, pretty.Fold(pretty.ConcatSpace, |
| 1512 | pretty.Keyword("ON"), |
| 1513 | p.Doc(&node.Table), |
| 1514 | p.bracket("(", p.Doc(&node.Columns), ")"))) |
| 1515 | |
| 1516 | if node.Sharded != nil { |
| 1517 | clauses = append(clauses, p.Doc(node.Sharded)) |
| 1518 | } |
| 1519 | if len(node.Storing) > 0 { |
| 1520 | clauses = append(clauses, p.bracketKeyword( |
| 1521 | "STORING", " (", |
| 1522 | p.Doc(&node.Storing), |
| 1523 | ")", "", |
| 1524 | )) |
| 1525 | } |
| 1526 | if node.Interleave != nil { |
| 1527 | clauses = append(clauses, p.Doc(node.Interleave)) |
| 1528 | } |
| 1529 | if node.PartitionBy != nil { |
| 1530 | clauses = append(clauses, p.Doc(node.PartitionBy)) |
| 1531 | } |
| 1532 | return p.nestUnder( |
| 1533 | pretty.Fold(pretty.ConcatSpace, title...), |
| 1534 | pretty.Group(pretty.Stack(clauses...))) |
| 1535 | } |
| 1536 | |
| 1537 | func (node *FamilyTableDef) doc(p *PrettyCfg) pretty.Doc { |
| 1538 | // Final layout: |