MCPcopy Create free account
hub / github.com/ajitpratap0/GoSQLX / renderCase

Function renderCase

pkg/formatter/render.go:1051–1083  ·  view source on GitHub ↗

─── expression renderers ─────────────────────────────────────────────────────

(c *ast.CaseExpression, opts ast.FormatOptions)

Source from the content-addressed store, hash-verified

1049// ─── expression renderers ─────────────────────────────────────────────────────
1050
1051func renderCase(c *ast.CaseExpression, opts ast.FormatOptions) string {
1052 if c == nil {
1053 return ""
1054 }
1055 f := newNodeFormatter(opts)
1056 sb := f.sb
1057
1058 sb.WriteString(f.kw("CASE"))
1059 if c.Value != nil {
1060 sb.WriteString(" ")
1061 sb.WriteString(FormatExpression(c.Value, opts))
1062 }
1063 for _, when := range c.WhenClauses {
1064 sb.WriteString(" ")
1065 sb.WriteString(f.kw("WHEN"))
1066 sb.WriteString(" ")
1067 sb.WriteString(FormatExpression(when.Condition, opts))
1068 sb.WriteString(" ")
1069 sb.WriteString(f.kw("THEN"))
1070 sb.WriteString(" ")
1071 sb.WriteString(FormatExpression(when.Result, opts))
1072 }
1073 if c.ElseClause != nil {
1074 sb.WriteString(" ")
1075 sb.WriteString(f.kw("ELSE"))
1076 sb.WriteString(" ")
1077 sb.WriteString(FormatExpression(c.ElseClause, opts))
1078 }
1079 sb.WriteString(" ")
1080 sb.WriteString(f.kw("END"))
1081
1082 return f.result()
1083}
1084
1085func renderBetween(b *ast.BetweenExpression, opts ast.FormatOptions) string {
1086 if b == nil {

Callers 1

FormatExpressionFunction · 0.85

Calls 4

newNodeFormatterFunction · 0.85
FormatExpressionFunction · 0.85
kwMethod · 0.80
resultMethod · 0.80

Tested by

no test coverage detected