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

Method SQL

pkg/sql/ast/sql.go:232–255  ·  view source on GitHub ↗

SQL returns the SQL representation of this CASE expression including all WHEN/THEN clauses and an optional ELSE clause.

()

Source from the content-addressed store, hash-verified

230// SQL returns the SQL representation of this CASE expression including all
231// WHEN/THEN clauses and an optional ELSE clause.
232func (c *CaseExpression) SQL() string {
233 if c == nil {
234 return ""
235 }
236 sb := getBuilder()
237 defer putBuilder(sb)
238 sb.WriteString("CASE")
239 if c.Value != nil {
240 sb.WriteString(" ")
241 sb.WriteString(exprSQL(c.Value))
242 }
243 for _, w := range c.WhenClauses {
244 sb.WriteString(" WHEN ")
245 sb.WriteString(exprSQL(w.Condition))
246 sb.WriteString(" THEN ")
247 sb.WriteString(exprSQL(w.Result))
248 }
249 if c.ElseClause != nil {
250 sb.WriteString(" ELSE ")
251 sb.WriteString(exprSQL(c.ElseClause))
252 }
253 sb.WriteString(" END")
254 return sb.String()
255}
256
257// SQL returns the SQL representation of this WHEN clause in the form
258// "WHEN condition THEN result".

Callers

nothing calls this directly

Calls 4

getBuilderFunction · 0.85
putBuilderFunction · 0.85
exprSQLFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected