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

Method Format

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

Source from the content-addressed store, hash-verified

15}
16
17func (n *DefElem) Format(buf *TrackedBuffer, d format.Dialect) {
18 if n == nil {
19 return
20 }
21 if n.Defname != nil {
22 switch *n.Defname {
23 case "as":
24 buf.WriteString("AS ")
25 // AS clause contains function body which needs quoting
26 if l, ok := n.Arg.(*List); ok {
27 for i, item := range l.Items {
28 if i > 0 {
29 buf.WriteString(", ")
30 }
31 if s, ok := item.(*String); ok {
32 buf.WriteString("'")
33 buf.WriteString(s.Str)
34 buf.WriteString("'")
35 } else {
36 buf.astFormat(item, d)
37 }
38 }
39 } else {
40 buf.astFormat(n.Arg, d)
41 }
42 case "language":
43 buf.WriteString("LANGUAGE ")
44 buf.astFormat(n.Arg, d)
45 case "volatility":
46 // VOLATILE, STABLE, IMMUTABLE
47 buf.astFormat(n.Arg, d)
48 case "strict":
49 if s, ok := n.Arg.(*Boolean); ok && s.Boolval {
50 buf.WriteString("STRICT")
51 } else {
52 buf.WriteString("CALLED ON NULL INPUT")
53 }
54 case "security":
55 if s, ok := n.Arg.(*Boolean); ok && s.Boolval {
56 buf.WriteString("SECURITY DEFINER")
57 } else {
58 buf.WriteString("SECURITY INVOKER")
59 }
60 default:
61 buf.WriteString(*n.Defname)
62 if n.Arg != nil {
63 buf.WriteString(" ")
64 buf.astFormat(n.Arg, d)
65 }
66 }
67 }
68}

Callers

nothing calls this directly

Calls 1

astFormatMethod · 0.80

Tested by

no test coverage detected