Could someone translate the following polish notation to its SQL counterpart:
['|', '&', ('is_company','=', True),('parent_id', '=', False),('company_name', '!=', False),('company_name', '!=', '')]
My guess is :
is_company = True OR parent_id = False AND company_name <> False AND company_name <> ''
I could not get the concept of this notation no matter how hard I tried to understand it. Please help.
UPDATE
I was trying to extend the above notation to be:
((is_company = True AND parent_id = False) OR company_name <> False) AND company_name <> '' AND customer_type_id <> False
I totally agree with you, each time I have to do a complex domain using this kind of Polish notation, I have to rack my brains to manage it.
I think the domain you're looking for is:
I made up a method to get these complex domains, and it's working:
First I write a letter instead of each condition:
Then build the expression you need using only the letters and the standard operators, forget about the Polish notation and the conditions:
Afterwards, group the operations you should execute the first (don't mind about the missing operators by the moment):
Now we have only an operator, let's start decomposing it again (and moving the operator to the left of each couple of conditions), following the reverse order in which you grouped the operations (for example, from step 3 to 4 you grouped DE, so now, from step 4 to 3, decompose DE and move its operator to its left):
Now change the operators and add the commas, the quotes and the brackets:
Finally, replace the letters with the conditions, and there you have your domain. It would be better to explain it face to face but may be you were able to understand everything.