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

Method Format

internal/sql/ast/join_expr.go:20–54  ·  view source on GitHub ↗
(buf *TrackedBuffer, d format.Dialect)

Source from the content-addressed store, hash-verified

18}
19
20func (n *JoinExpr) Format(buf *TrackedBuffer, d format.Dialect) {
21 if n == nil {
22 return
23 }
24 buf.astFormat(n.Larg, d)
25 if n.IsNatural {
26 buf.WriteString(" NATURAL")
27 }
28 switch n.Jointype {
29 case JoinTypeLeft:
30 buf.WriteString(" LEFT JOIN ")
31 case JoinTypeRight:
32 buf.WriteString(" RIGHT JOIN ")
33 case JoinTypeFull:
34 buf.WriteString(" FULL JOIN ")
35 case JoinTypeInner:
36 // CROSS JOIN has no ON or USING clause
37 if !items(n.UsingClause) && !set(n.Quals) {
38 buf.WriteString(" CROSS JOIN ")
39 } else {
40 buf.WriteString(" JOIN ")
41 }
42 default:
43 buf.WriteString(" JOIN ")
44 }
45 buf.astFormat(n.Rarg, d)
46 if items(n.UsingClause) {
47 buf.WriteString(" USING (")
48 buf.join(n.UsingClause, d, ", ")
49 buf.WriteString(")")
50 } else if set(n.Quals) {
51 buf.WriteString(" ON ")
52 buf.astFormat(n.Quals, d)
53 }
54}

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