rulerz icon indicating copy to clipboard operation
rulerz copied to clipboard

Understanding of brackets placement

Open n10ty opened this issue 8 years ago • 0 comments

I need to sync my understanding of how and why rulerz place brackets. Below you can see several examples. Condidtion: $rules = '1 = 1 and 1 = 1 and 1 = 1 or 1 = 1'; Result in query: WHERE ((1 = 1 AND (1 = 1 AND (1 = 1 OR 1 = 1))))

Condition: (1 = 1) and ((1 = 1) or (1 = 1) or (1 = 1)) and (1 = 1 or 1 = 1 or 1 = 1) Result: ((1 = 1 AND ((1 = 1 OR (1 = 1 OR 1 = 1)) AND (1 = 1 OR (1 = 1 OR 1 = 1)))))

In the second example, it increases the deep of Doctrine query. In result: simple condition becomes enormous. So, I have a situation where I need only a lot of conditions joined with OR, but after adding brackets it becomes 256 nested level error. I don't understand it. Is it always add brackets? How should I avoid this? Why it so? What is the main idea of it? I didn't find any mention of this case in documentation. Thank for your answer, your library is really great.

n10ty avatar Dec 01 '16 13:12 n10ty