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

Function op_precedence

src/sql-parser/tests/sqlparser_common.rs:46–85  ·  view source on GitHub ↗

unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`

()

Source from the content-addressed store, hash-verified

44#[mz_ore::test]
45#[cfg_attr(miri, ignore)] // unsupported operation: can't call foreign function `rust_psm_stack_pointer` on OS `linux`
46fn op_precedence() -> Result<(), Box<dyn Error>> {
47 struct RemoveParens;
48
49 impl<'a> VisitMut<'a, Raw> for RemoveParens {
50 fn visit_expr_mut(&mut self, expr: &'a mut Expr<Raw>) {
51 if let Expr::Nested(e) = expr {
52 *expr = (**e).clone();
53 }
54 visit_mut::visit_expr_mut(self, expr);
55 }
56 }
57
58 for (actual, expected) in &[
59 ("a + b + c", "(a + b) + c"),
60 ("a - b + c", "(a - b) + c"),
61 ("a + b * c", "a + (b * c)"),
62 ("true = 'foo' like 'foo'", "true = ('foo' like 'foo')"),
63 ("a->b = c->d", "(a->b) = (c->d)"),
64 ("a @> b = c @> d", "(a @> b) = (c @> d)"),
65 ("a = b is null", "(a = b) is null"),
66 ("a and b or c and d", "(a and b) or (c and d)"),
67 ("+ a / b", "(+ a) / b"),
68 ("NOT true OR true", "(NOT true) OR true"),
69 ("NOT a IS NULL", "NOT (a IS NULL)"),
70 ("NOT 1 NOT BETWEEN 1 AND 2", "NOT (1 NOT BETWEEN 1 AND 2)"),
71 ("NOT a NOT LIKE b", "NOT (a NOT LIKE b)"),
72 ("NOT a NOT IN ('a')", "NOT (a NOT IN ('a'))"),
73 ("+ a / b COLLATE coll", "(+a) / (b COLLATE coll)"),
74 ("- ts AT TIME ZONE 'tz'", "(-ts) AT TIME ZONE 'tz'"),
75 ("a[b].c::d", "((a[b]).c)::d"),
76 ("2 OPERATOR(*) 2 + 2", "2 OPERATOR(*) (2 + 2)"),
77 ] {
78 let left = parser::parse_expr(actual)?;
79 let mut right = parser::parse_expr(expected)?;
80 RemoveParens.visit_expr_mut(&mut right);
81
82 assert_eq!(left, right);
83 }
84 Ok(())
85}
86
87#[mz_ore::test]
88fn format_ident() {

Callers

nothing calls this directly

Calls 2

parse_exprFunction · 0.50
visit_expr_mutMethod · 0.45

Tested by

no test coverage detected