Skip to main content

prints_self_delimiting

Function prints_self_delimiting 

Source
fn prints_self_delimiting<T: AstInfo>(expr: &Expr<T>) -> bool
Expand description

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(<needle> IN …) special form) without the operator re-associating into the expression’s spine.

Anything with an exposed operator spine is not self-delimiting: a tight postfix would bind to its rightmost sub-operand (a + b COLLATE c parses as a + (b COLLATE c)), and the position IN delimiter would split on an inner IN/comparison (a IN (q) ->> b). Callers must parenthesize / fall back for those. Postfix forms (::/COLLATE/[…]) are self-delimiting only when their own inner operand is.