I am writing a wrapper for SQL Conditions ( so that I can use them in my where statement that I also have a wrapper for ).
Idea is that all of them would be valid :
>> condition_a = Condition("x","=","5")
>> condition_b = Condition("y",">","6")
>> c = condition_a & condition_b
which should give me " x = 5 AND y > 6 "
that is fine so far - I can do so by overloading and, and or.
I don't know what I should overload to have ( working like this ?
>> condition_a = Condition("x","=","5")
>> condition_b = Condition("y",">","6")
>> condition_c = Condition("z",">","7")
>> d = condition_c & ( condition_a | condition_b )
which should give me " z > 7 AND ( x = 5 OR y > 6 ) "
Sceleton for my condition class is :
class Condition( object ) :
def __init__( self , args ) :
....
def __and__( self , other ) :
...
def __or__( self , other ) :
...
How can i do that?
condition_a | condition_bshould result in a newConditionGrouplike object as an operand to following computation.