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

Function write_quantified_left

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

Write `left` as the LHS of ` ANY/ALL (...)`. The printed ` ` is an ordinary binary infix. It can be any operator the parser accepts here, from `=`/`<` (`Cmp`) all the way down to `*`/`/`/`%` (`MultiplyDivide`), and on reparse it binds into any operator exposed on `left`'s right spine that is strictly looser* than ` ` itself, stealing that suffix into the quantified expression's le

(
    f: &mut AstFormatter<W>,
    expr: &Expr<T>,
    op: &Op,
)

Source from the content-addressed store, hash-verified

627/// `a + (b * ANY (…))`. [`right_edge`] also sees a looser spine hidden under
628/// right-transparent prefixes, e.g. the `NOT`'s `IN` in `- NOT a IN (b) = ANY (…)`.
629fn write_quantified_left<W: fmt::Write, T: AstInfo>(
630 f: &mut AstFormatter<W>,
631 expr: &Expr<T>,
632 op: &Op,
633) {
634 let needs_parens = right_edge(expr) < binary_op_precedence(op);
635 if needs_parens {
636 f.write_str("(");
637 f.write_node(expr);
638 f.write_str(")");
639 } else {
640 f.write_node(expr);
641 }
642}
643
644/// Write `bound` as a `BETWEEN … AND …` bound. The parser parses both bounds with
645/// `parse_subexpr(Precedence::Like)` (see `Parser::parse_between`), starting fresh

Callers 1

fmtMethod · 0.85

Calls 4

right_edgeFunction · 0.85
binary_op_precedenceFunction · 0.85
write_nodeMethod · 0.80
write_strMethod · 0.45

Tested by

no test coverage detected