MCPcopy Create free account
hub / github.com/dolthub/doltgresql / doc

Method doc

postgres/parser/sem/tree/pretty.go:945–989  ·  view source on GitHub ↗
(p *PrettyCfg)

Source from the content-addressed store, hash-verified

943}
944
945func (node *Insert) doc(p *PrettyCfg) pretty.Doc {
946 items := make([]pretty.TableRow, 0, 8)
947 items = append(items, node.With.docRow(p))
948 kw := "INSERT"
949 if node.OnConflict.IsUpsertAlias() {
950 kw = "UPSERT"
951 }
952 items = append(items, p.row(kw, pretty.Nil))
953
954 into := p.Doc(node.Table)
955 if node.Columns != nil {
956 into = p.nestUnder(into, p.bracket("(", p.Doc(&node.Columns), ")"))
957 }
958 items = append(items, p.row("INTO", into))
959
960 if node.DefaultValues() {
961 items = append(items, p.row("", pretty.Keyword("DEFAULT VALUES")))
962 } else {
963 items = append(items, node.Rows.docTable(p)...)
964 }
965
966 if node.OnConflict != nil && !node.OnConflict.IsUpsertAlias() {
967 cond := pretty.Nil
968 if len(node.OnConflict.Columns) > 0 {
969 cond = p.bracket("(", p.Doc(&node.OnConflict.Columns), ")")
970 }
971 items = append(items, p.row("ON CONFLICT", cond))
972 if node.OnConflict.ArbiterPredicate != nil {
973 items = append(items, p.row("WHERE", p.Doc(node.OnConflict.ArbiterPredicate)))
974 }
975
976 if node.OnConflict.DoNothing {
977 items = append(items, p.row("DO", pretty.Keyword("NOTHING")))
978 } else {
979 items = append(items, p.row("DO",
980 p.nestUnder(pretty.Keyword("UPDATE SET"), p.Doc(&node.OnConflict.Exprs))))
981 if node.OnConflict.Where != nil {
982 items = append(items, node.OnConflict.Where.docRow(p))
983 }
984 }
985 }
986
987 items = append(items, p.docReturning(node.Returning))
988 return p.rlTable(items...)
989}
990
991func (node *NameList) doc(p *PrettyCfg) pretty.Doc {
992 d := make([]pretty.Doc, len(*node))

Callers

nothing calls this directly

Calls 11

DefaultValuesMethod · 0.95
KeywordFunction · 0.92
IsUpsertAliasMethod · 0.80
rowMethod · 0.80
DocMethod · 0.80
nestUnderMethod · 0.80
bracketMethod · 0.80
docReturningMethod · 0.80
rlTableMethod · 0.80
docTableMethod · 0.65
docRowMethod · 0.45

Tested by

no test coverage detected