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

Method Format

internal/sql/ast/bool_expr.go:16–49  ·  view source on GitHub ↗
(buf *TrackedBuffer, d format.Dialect)

Source from the content-addressed store, hash-verified

14}
15
16func (n *BoolExpr) Format(buf *TrackedBuffer, d format.Dialect) {
17 if n == nil {
18 return
19 }
20 switch n.Boolop {
21 case BoolExprTypeIsNull:
22 if items(n.Args) && len(n.Args.Items) > 0 {
23 buf.astFormat(n.Args.Items[0], d)
24 }
25 buf.WriteString(" IS NULL")
26 case BoolExprTypeIsNotNull:
27 if items(n.Args) && len(n.Args.Items) > 0 {
28 buf.astFormat(n.Args.Items[0], d)
29 }
30 buf.WriteString(" IS NOT NULL")
31 case BoolExprTypeNot:
32 // NOT expression: format as NOT <arg>
33 buf.WriteString("NOT ")
34 if items(n.Args) && len(n.Args.Items) > 0 {
35 buf.astFormat(n.Args.Items[0], d)
36 }
37 default:
38 buf.WriteString("(")
39 if items(n.Args) {
40 switch n.Boolop {
41 case BoolExprTypeAnd:
42 buf.join(n.Args, d, " AND ")
43 case BoolExprTypeOr:
44 buf.join(n.Args, d, " OR ")
45 }
46 }
47 buf.WriteString(")")
48 }
49}

Callers

nothing calls this directly

Calls 3

itemsFunction · 0.85
astFormatMethod · 0.80
joinMethod · 0.80

Tested by

no test coverage detected