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

Method doc

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

Source from the content-addressed store, hash-verified

913}
914
915func (node *Insert) doc(p *PrettyCfg) pretty.Doc {
916 items := make([]pretty.TableRow, 0, 8)
917 items = append(items, node.With.docRow(p))
918 kw := "INSERT"
919 if node.OnConflict.IsUpsertAlias() {
920 kw = "UPSERT"
921 }
922 items = append(items, p.row(kw, pretty.Nil))
923
924 into := p.Doc(node.Table)
925 if node.Columns != nil {
926 into = p.nestUnder(into, p.bracket("(", p.Doc(&node.Columns), ")"))
927 }
928 items = append(items, p.row("INTO", into))
929
930 if node.DefaultValues() {
931 items = append(items, p.row("", pretty.Keyword("DEFAULT VALUES")))
932 } else {
933 items = append(items, node.Rows.docTable(p)...)
934 }
935
936 if node.OnConflict != nil && !node.OnConflict.IsUpsertAlias() {
937 cond := pretty.Nil
938 if len(node.OnConflict.Columns) > 0 {
939 cond = p.bracket("(", p.Doc(&node.OnConflict.Columns), ")")
940 }
941 items = append(items, p.row("ON CONFLICT", cond))
942
943 if node.OnConflict.DoNothing {
944 items = append(items, p.row("DO", pretty.Keyword("NOTHING")))
945 } else {
946 items = append(items, p.row("DO",
947 p.nestUnder(pretty.Keyword("UPDATE SET"), p.Doc(&node.OnConflict.Exprs))))
948 if node.OnConflict.Where != nil {
949 items = append(items, node.OnConflict.Where.docRow(p))
950 }
951 }
952 }
953
954 items = append(items, p.docReturning(node.Returning))
955 return p.rlTable(items...)
956}
957
958func (node *NameList) doc(p *PrettyCfg) pretty.Doc {
959 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