MCPcopy Create free account
hub / github.com/auxten/postgresql-parser / doc

Method doc

pkg/sql/sem/tree/pretty.go:1609–1656  ·  view source on GitHub ↗
(p *PrettyCfg)

Source from the content-addressed store, hash-verified

1607}
1608
1609func (node *UniqueConstraintTableDef) doc(p *PrettyCfg) pretty.Doc {
1610 // Final layout:
1611 // [CONSTRAINT name]
1612 // [PRIMARY KEY|UNIQUE] ( ... )
1613 // [STORING ( ... )]
1614 // [INTERLEAVE ...]
1615 // [PARTITION BY ...]
1616 //
1617 // or (no constraint name):
1618 //
1619 // [PRIMARY KEY|UNIQUE] ( ... )
1620 // [STORING ( ... )]
1621 // [INTERLEAVE ...]
1622 // [PARTITION BY ...]
1623 //
1624 clauses := make([]pretty.Doc, 0, 5)
1625 var title pretty.Doc
1626 if node.PrimaryKey {
1627 title = pretty.Keyword("PRIMARY KEY")
1628 } else {
1629 title = pretty.Keyword("UNIQUE")
1630 }
1631 title = pretty.ConcatSpace(title, p.bracket("(", p.Doc(&node.Columns), ")"))
1632 if node.Name != "" {
1633 clauses = append(clauses, title)
1634 title = pretty.ConcatSpace(pretty.Keyword("CONSTRAINT"), p.Doc(&node.Name))
1635 }
1636 if node.Sharded != nil {
1637 clauses = append(clauses, p.Doc(node.Sharded))
1638 }
1639 if node.Storing != nil {
1640 clauses = append(clauses, p.bracketKeyword(
1641 "STORING", "(",
1642 p.Doc(&node.Storing),
1643 ")", ""))
1644 }
1645 if node.Interleave != nil {
1646 clauses = append(clauses, p.Doc(node.Interleave))
1647 }
1648 if node.PartitionBy != nil {
1649 clauses = append(clauses, p.Doc(node.PartitionBy))
1650 }
1651
1652 if len(clauses) == 0 {
1653 return title
1654 }
1655 return p.nestUnder(title, pretty.Group(pretty.Stack(clauses...)))
1656}
1657
1658func (node *ForeignKeyConstraintTableDef) doc(p *PrettyCfg) pretty.Doc {
1659 // Final layout:

Callers

nothing calls this directly

Calls 8

KeywordFunction · 0.92
ConcatSpaceFunction · 0.92
GroupFunction · 0.92
StackFunction · 0.92
bracketMethod · 0.80
DocMethod · 0.80
bracketKeywordMethod · 0.80
nestUnderMethod · 0.80

Tested by

no test coverage detected