Пример #1
0
 def test_unary_both_ops(self):
     assert_raises_message(
         exc.CompileError, "Unary expression does not support operator and "
         "modifier simultaneously",
         UnaryExpression(literal("x"),
                         operator=operators.custom_op("x"),
                         modifier=operators.custom_op("y")).compile)
Пример #2
0
 def expression(self, args):
     if len(args) == 1:
         # it's a list expression
         return args[0]
     left, op, right = args
     inverse = False
     if type(op) is tuple:
         op = op[0]
         inverse = True
     exp = BinaryExpression(left, right, op)
     if inverse:
         exp = UnaryExpression(exp, operator=operator.inv)
     return exp
Пример #3
0
def ttl_delete(expr):
    return UnaryExpression(expr, modifier=custom_op('DELETE'))
Пример #4
0
 def test_unary_no_ops(self):
     assert_raises_message(
         exc.CompileError,
         "Unary expression has no operator or modifier",
         UnaryExpression(literal("x")).compile
     )
Пример #5
0
 def factorial_prefix(self):
     return UnaryExpression(self.expr,
                 operator=operators.custom_op("!!"),
                 type_=MyInteger)
Пример #6
0
 def factorial(self):
     return UnaryExpression(self.expr,
                 modifier=operators.custom_op("!"),
                 type_=MyInteger)