(e ast.Expr, parent string)
| 69 | } |
| 70 | |
| 71 | func (c *canon) expr(e ast.Expr, parent string) { |
| 72 | switch e := e.(type) { |
| 73 | case nil: |
| 74 | c.write("null") |
| 75 | case *ast.AggFuncExpr: |
| 76 | var distinct string |
| 77 | if e.Distinct { |
| 78 | distinct = "distinct " |
| 79 | } |
| 80 | c.write("%s(%s", e.Name, distinct) |
| 81 | if e.Expr != nil { |
| 82 | c.expr(e.Expr, "") |
| 83 | } |
| 84 | c.write(")") |
| 85 | if e.Filter != nil { |
| 86 | c.write(" filter ") |
| 87 | c.expr(e.Filter, "") |
| 88 | } |
| 89 | case *ast.SQLAsExpr: |
| 90 | c.expr(e.Expr, "") |
| 91 | if e.Label != nil { |
| 92 | c.write(" as %s", e.Label.Name) |
| 93 | } |
| 94 | case *ast.Primitive: |
| 95 | c.literal(*e) |
| 96 | case *ast.IDExpr: |
| 97 | c.write(e.Name) |
| 98 | case *ast.DoubleQuoteExpr: |
| 99 | c.write("%q", e.Text) |
| 100 | case *ast.UnaryExpr: |
| 101 | c.write(e.Op) |
| 102 | c.expr(e.Operand, "not") |
| 103 | case *ast.BinaryExpr: |
| 104 | c.binary(e, parent) |
| 105 | case *ast.CondExpr: |
| 106 | c.write("(") |
| 107 | c.expr(e.Cond, "") |
| 108 | c.write(") ? ") |
| 109 | c.expr(e.Then, "") |
| 110 | c.write(" : ") |
| 111 | c.expr(e.Else, "") |
| 112 | case *ast.CallExpr: |
| 113 | c.funcRefAsCall(e.Func) |
| 114 | c.write("(") |
| 115 | c.exprs(e.Args) |
| 116 | c.write(")") |
| 117 | case *ast.CaseExpr: |
| 118 | c.write("case") |
| 119 | if e.Expr != nil { |
| 120 | c.write(" ") |
| 121 | c.expr(e.Expr, "") |
| 122 | } |
| 123 | for _, when := range e.Whens { |
| 124 | c.write(" when ") |
| 125 | c.expr(when.Cond, "") |
| 126 | c.write(" then ") |
| 127 | c.expr(when.Then, "") |
| 128 | } |
no test coverage detected