MCPcopy
hub / github.com/sqlc-dev/sqlc / Format

Method Format

internal/sql/ast/insert_stmt.go:21–62  ·  view source on GitHub ↗
(buf *TrackedBuffer, d format.Dialect)

Source from the content-addressed store, hash-verified

19}
20
21func (n *InsertStmt) Format(buf *TrackedBuffer, d format.Dialect) {
22 if n == nil {
23 return
24 }
25
26 if n.WithClause != nil {
27 buf.astFormat(n.WithClause, d)
28 buf.WriteString(" ")
29 }
30
31 buf.WriteString("INSERT INTO ")
32 if n.Relation != nil {
33 buf.astFormat(n.Relation, d)
34 }
35 if items(n.Cols) {
36 buf.WriteString(" (")
37 buf.astFormat(n.Cols, d)
38 buf.WriteString(")")
39 }
40
41 if n.DefaultValues {
42 buf.WriteString(" DEFAULT VALUES")
43 } else if set(n.SelectStmt) {
44 buf.WriteString(" ")
45 buf.astFormat(n.SelectStmt, d)
46 }
47
48 if n.OnConflictClause != nil {
49 buf.WriteString(" ")
50 buf.astFormat(n.OnConflictClause, d)
51 }
52
53 if n.OnDuplicateKeyUpdate != nil {
54 buf.WriteString(" ")
55 buf.astFormat(n.OnDuplicateKeyUpdate, d)
56 }
57
58 if items(n.ReturningList) {
59 buf.WriteString(" RETURNING ")
60 buf.astFormat(n.ReturningList, d)
61 }
62}

Callers

nothing calls this directly

Calls 3

itemsFunction · 0.85
setFunction · 0.85
astFormatMethod · 0.80

Tested by

no test coverage detected