Format implements the NodeFormatter interface.
(ctx *FmtCtx)
| 1628 | |
| 1629 | // Format implements the NodeFormatter interface. |
| 1630 | func (node *AnnotateTypeExpr) Format(ctx *FmtCtx) { |
| 1631 | if ctx.HasFlags(FmtPGAttrdefAdbin) { |
| 1632 | ctx.FormatNode(node.Expr) |
| 1633 | switch node.Type.Family() { |
| 1634 | case types.StringFamily, types.CollatedStringFamily: |
| 1635 | // Postgres formats strings using a cast afterward. Let's do the same. |
| 1636 | ctx.WriteString("::") |
| 1637 | ctx.WriteString(node.Type.SQLString()) |
| 1638 | } |
| 1639 | return |
| 1640 | } |
| 1641 | switch node.SyntaxMode { |
| 1642 | case AnnotateShort: |
| 1643 | exprFmtWithParen(ctx, node.Expr) |
| 1644 | ctx.WriteString(":::") |
| 1645 | ctx.WriteString(node.Type.SQLString()) |
| 1646 | |
| 1647 | default: |
| 1648 | ctx.WriteString("ANNOTATE_TYPE(") |
| 1649 | ctx.FormatNode(node.Expr) |
| 1650 | ctx.WriteString(", ") |
| 1651 | ctx.WriteString(node.Type.SQLString()) |
| 1652 | ctx.WriteByte(')') |
| 1653 | } |
| 1654 | } |
| 1655 | |
| 1656 | // TypedInnerExpr returns the AnnotateTypeExpr's inner expression as a TypedExpr. |
| 1657 | func (node *AnnotateTypeExpr) TypedInnerExpr() TypedExpr { |
nothing calls this directly
no test coverage detected