Kinda curious about operator precedence
# spicedb
w
Kinda curious about operator precedence and schema generation. It looks like it's not really documented, but, it seems like the generator library in the schemadsl package is aware of it, ie something like (A intersect (B union C)) gets emitted as a & b + c while ((A intersect B) except C) gets emitted as (a & b) - c I guess I have two questions: 1. Does that sound right? Does the generator package automatically handle parens as-needed? 2. Assuming #1, if I wanted to override this behavior for readability and add semantically unnecessary parentheses, ie: a & (b + c), is there a way to do that?
j
1. yes
2. no; the generator will remove parens when it feels it isn't necessary
if you want to enforce it, break the subexpression into its own permission
the precedence rules may change in the future, but will never do so without a schema version bump
when in doubt, we do recommend breaking into other permissions anyway, as its more readable