SQL returns the SQL representation of this CASE expression including all WHEN/THEN clauses and an optional ELSE clause.
()
| 230 | // SQL returns the SQL representation of this CASE expression including all |
| 231 | // WHEN/THEN clauses and an optional ELSE clause. |
| 232 | func (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". |
nothing calls this directly
no test coverage detected