Write `bound` as a `BETWEEN … AND …` bound. The parser parses both bounds with `parse_subexpr(Precedence::Like)` (see `Parser::parse_between`), starting fresh with nothing to the bound's left, so it walks the bound's *left spine* and stops at the first operator binding at or below `Like`, leaving that operator outside the bound (`x BETWEEN 1 IS NULL AND y` parses `1` as the bound, then expects `AN
(f: &mut AstFormatter<W>, bound: &Expr<T>)
| 653 | /// `Expr::Nested` (which is `ATOM`, so it prints bare). This re-adds the parens |
| 654 | /// for ASTs where that wrapper is absent. |
| 655 | fn write_between_bound<W: fmt::Write, T: AstInfo>(f: &mut AstFormatter<W>, bound: &Expr<T>) { |
| 656 | let needs_parens = left_edge(bound) <= prec::LIKE; |
| 657 | if needs_parens { |
| 658 | f.write_str("("); |
| 659 | f.write_node(bound); |
| 660 | f.write_str(")"); |
| 661 | } else { |
| 662 | f.write_node(bound); |
| 663 | } |
| 664 | } |
| 665 | |
| 666 | /// Output-precedence ranks, derived directly from the parser's [`Precedence`] |
| 667 | /// ladder (higher binds tighter) so it stays the single source of truth: |
no test coverage detected