writeExpression writes the SQL expression for the given expression. The output is guaranteed to be wrapped in parentheses.
(e *Expression)
| 41 | // writeExpression writes the SQL expression for the given expression. |
| 42 | // The output is guaranteed to be wrapped in parentheses. |
| 43 | func (b *sqlExprBuilder) writeExpression(e *Expression) error { |
| 44 | if e == nil { |
| 45 | return nil |
| 46 | } |
| 47 | if e.Name != "" { |
| 48 | return b.writeName(e.Name) |
| 49 | } |
| 50 | if e.Value != nil { |
| 51 | return b.writeValue(e.Value) |
| 52 | } |
| 53 | if e.Subquery != nil { |
| 54 | return b.writeSubquery(e.Subquery) |
| 55 | } |
| 56 | if e.Condition != nil { |
| 57 | return b.writeCondition(e.Condition) |
| 58 | } |
| 59 | return errors.New("invalid expression (must contain one of name, val, cond, subquery)") |
| 60 | } |
| 61 | |
| 62 | func (b *sqlExprBuilder) writeName(name string) error { |
| 63 | expr, unnest, _, err := b.sqlForName(name) |
no test coverage detected