Unsure about "or" operator in privacy rules

I am unsure about the “or” operator in Bubble for privacy rules. If you have something like:

Current User’s Account’s Admins contains Current User and This Course’s Account is Current User’s Account or This Course’s Account is empty

The expression might be evaluated in two different ways, depending on how Bubble prioritizes and groups the conditions:

  1. (Current User’s Account’s Admins contains Current User AND This Course’s Account is Current User’s Account) OR This Course’s Account is empty Here, the first two conditions are grouped together. If either this combined condition is true, or “This Course’s Account is empty” is true, then the overall condition is met.
  2. Current User’s Account’s Admins contains Current User AND (This Course’s Account is Current User’s Account OR This Course’s Account is empty) In this interpretation, the second and third conditions are grouped. The overall condition is met if the current user is an admin of their account, and either the course account is their account or the course account is empty.

Without explicit grouping (using parentheses), the evaluation can be ambiguous.

1 Like

Hi there, @RPSM… I honestly can’t remember how that expression would be evaluated since the experimental parentheses feature was introduced the better part of 2 years ago. So, I would suggest you either enable that feature (which you can do on the Settings >> Versions tab) or enable the new expression composer (which, full disclosure, is still in beta and pretty buggy), and you will be able to eliminate the ambiguity by grouping parts of the expression to meet your requirements.

Hope this helps.

Best…
Mike

3 Likes

Ah, excellent, I had not thought to look in the beta features. Thank you, this makes a lot of sense.

2 Likes

I (and many others) have been using the experimental parentheses feature without much (if any) trouble since it was introduced, and the new expression composer has been getting better as Bubble continues to work on it.

3 Likes

The old expression composer (without parenthesis) always evaluated left to right, without considering order of operation.

So in your situation it would evaluate as option 1.

However, as @mikeloc said, it would be a good shout to activate the parenthesis on your app’s settings. I honestly cant recommend it enough and never had problems with it. I think the time has come for Bubble to set it as default.
However id give the new expression composer a bit of time, it is still a bit unstable.

2 Likes