MCPcopy Create free account
hub / github.com/MaterializeInc/materialize / write_binary_operand

Function write_binary_operand

src/sql-parser/src/ast/defs/expr.rs:815–827  ·  view source on GitHub ↗

Write `operand` for a binary operator, parenthesizing it iff `needs_parens`.

(
    f: &mut AstFormatter<W>,
    operand: &Expr<T>,
    needs_parens: bool,
)

Source from the content-addressed store, hash-verified

813
814/// Write `operand` for a binary operator, parenthesizing it iff `needs_parens`.
815fn write_binary_operand<W: fmt::Write, T: AstInfo>(
816 f: &mut AstFormatter<W>,
817 operand: &Expr<T>,
818 needs_parens: bool,
819) {
820 if needs_parens {
821 f.write_str("(");
822 f.write_node(operand);
823 f.write_str(")");
824 } else {
825 f.write_node(operand);
826 }
827}
828
829/// Whether `expr` prints in a *self-delimiting* form — atomic, or wrapped in its
830/// own brackets/parens (`name(...)`, `(…)`, `ARRAY[…]`, `CASE … END`, …) — so it

Callers 1

fmtMethod · 0.85

Calls 2

write_nodeMethod · 0.80
write_strMethod · 0.45

Tested by

no test coverage detected