Whether `expr` prints in a *self-delimiting* form — atomic, or wrapped in its own brackets/parens (`name(...)`, `(…)`, `ARRAY[…]`, `CASE … END`, …) — so it is safe to print immediately to the left of a tight postfix operator (`::`, `COLLATE`, or the `IN` delimiter of the `position( IN …)` special form) without the operator re-associating into the expression's spine. Anything with an expos
(expr: &Expr<T>)
| 839 | /// back for those. Postfix forms (`::`/`COLLATE`/`[…]`) are self-delimiting only |
| 840 | /// when their own inner operand is. |
| 841 | fn prints_self_delimiting<T: AstInfo>(expr: &Expr<T>) -> bool { |
| 842 | match expr { |
| 843 | Expr::Value(_) |
| 844 | | Expr::Identifier(_) |
| 845 | | Expr::QualifiedWildcard(_) |
| 846 | | Expr::Parameter(_) |
| 847 | | Expr::Function(_) |
| 848 | | Expr::HomogenizingFunction { .. } |
| 849 | | Expr::NullIf { .. } |
| 850 | | Expr::Subquery(_) |
| 851 | | Expr::Exists(_) |
| 852 | | Expr::Nested(_) |
| 853 | | Expr::Array(_) |
| 854 | | Expr::ArraySubquery(_) |
| 855 | | Expr::List(_) |
| 856 | | Expr::ListSubquery(_) |
| 857 | | Expr::Map(_) |
| 858 | | Expr::MapSubquery(_) |
| 859 | | Expr::Case { .. } |
| 860 | | Expr::Row { .. } => true, |
| 861 | // The postfix `::` / `COLLATE` / `[…]` forms print as `<inner><suffix>`, |
| 862 | // so they are safe only when their inner operand is. |
| 863 | Expr::Cast { expr, .. } | Expr::Collate { expr, .. } | Expr::Subscript { expr, .. } => { |
| 864 | prints_self_delimiting(expr) |
| 865 | } |
| 866 | _ => false, |
| 867 | } |
| 868 | } |
| 869 | |
| 870 | /// Whether the operand of a prefix operator (`-`/`+`/`~`) must be parenthesized |
| 871 | /// to round-trip. A prefix op binds *tighter* than `COLLATE`/`AT TIME ZONE` and |
no outgoing calls
no test coverage detected