MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / Format

Method Format

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

Source from the content-addressed store, hash-verified

19}
20
21func (n *DeleteStmt) 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("DELETE ")
32
33 // MySQL multi-table DELETE: DELETE t1.*, t2.* FROM t1 JOIN t2 ...
34 if items(n.Targets) {
35 buf.join(n.Targets, d, ", ")
36 buf.WriteString(" FROM ")
37 if set(n.FromClause) {
38 buf.astFormat(n.FromClause, d)
39 } else if items(n.Relations) {
40 buf.astFormat(n.Relations, d)
41 }
42 } else {
43 buf.WriteString("FROM ")
44 if items(n.Relations) {
45 buf.astFormat(n.Relations, d)
46 }
47 }
48
49 if items(n.UsingClause) {
50 buf.WriteString(" USING ")
51 buf.join(n.UsingClause, d, ", ")
52 }
53
54 if set(n.WhereClause) {
55 buf.WriteString(" WHERE ")
56 buf.astFormat(n.WhereClause, d)
57 }
58
59 if set(n.LimitCount) {
60 buf.WriteString(" LIMIT ")
61 buf.astFormat(n.LimitCount, d)
62 }
63
64 if items(n.ReturningList) {
65 buf.WriteString(" RETURNING ")
66 buf.astFormat(n.ReturningList, d)
67 }
68}

Callers

nothing calls this directly

Calls 4

itemsFunction · 0.85
setFunction · 0.85
astFormatMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected