Add reversed operators to PYSON expressions
review8201002 issue4856
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
* Add reversed operators to PYSON expressions
|
||||
* Use CURRENT_TIMESTAMP instead of now
|
||||
* Use Constraint instance in ModelSQL._sql_constraints
|
||||
* Only return default record if no domain supplied on ModelSingleton search
|
||||
|
||||
@@ -56,6 +56,8 @@ class PYSON(object):
|
||||
else:
|
||||
return And(self, other)
|
||||
|
||||
__rand__ = __and__
|
||||
|
||||
def __or__(self, other):
|
||||
if (isinstance(other, PYSON)
|
||||
and other.types() != set([bool])):
|
||||
@@ -68,6 +70,8 @@ class PYSON(object):
|
||||
else:
|
||||
return Or(self, other)
|
||||
|
||||
__ror__ = __or__
|
||||
|
||||
def __eq__(self, other):
|
||||
return Equal(self, other)
|
||||
|
||||
|
||||
@@ -33,6 +33,12 @@ class PYSONTestCase(unittest.TestCase):
|
||||
self.assertEqual(repr(pyson.Eval('test', 'foo')),
|
||||
"Eval('test', 'foo')")
|
||||
|
||||
self.assertIsInstance(~pyson.Eval('test', False), pyson.Not)
|
||||
self.assertIsInstance(pyson.Eval('test', False) & True, pyson.And)
|
||||
self.assertIsInstance(True & pyson.Eval('test', False), pyson.And)
|
||||
self.assertIsInstance(pyson.Eval('test', False) | False, pyson.Or)
|
||||
self.assertIsInstance(False | pyson.Eval('test', False), pyson.Or)
|
||||
|
||||
def test0020Not(self):
|
||||
'Test pyson.Not'
|
||||
self.assertEqual(pyson.Not(True).pyson(), {
|
||||
|
||||
Reference in New Issue
Block a user