Ejemplo n.º 1
0
 def test_null_comparison_functions(self):
     self.assert_parsed_select(
         'SELECT foo IS NULL, bar IS NOT NULL FROM table',
         tq_ast.Select([
             tq_ast.SelectField(
                 tq_ast.UnaryOperator('is_null', tq_ast.ColumnId('foo')),
                 None),
             tq_ast.SelectField(
                 tq_ast.UnaryOperator('is_not_null',
                                      tq_ast.ColumnId('bar')), None)
         ], tq_ast.TableId('table', None), None, None, None, None, None))
Ejemplo n.º 2
0
 def test_negative_numbers(self):
     self.assert_parsed_select(
         'SELECT -5',
         tq_ast.Select([
             tq_ast.SelectField(tq_ast.UnaryOperator('-', literal(5)), None)
         ], None, None, None, None, None, None),
     )
Ejemplo n.º 3
0
 def test_function_calls(self):
     self.assert_parsed_select(
         'SELECT ABS(-3), POW(2, 3), NOW()',
         tq_ast.Select([
             tq_ast.SelectField(
                 tq_ast.FunctionCall('abs', [
                     tq_ast.UnaryOperator('-', literal(3))
                 ]),
                 None
             ),
             tq_ast.SelectField(
                 tq_ast.FunctionCall('pow', [literal(2), literal(3)]),
                 None
             ),
             tq_ast.SelectField(
                 tq_ast.FunctionCall('now', []),
                 None
             )],
             None,
             None,
             None,
             None,
             None,
             None
         )
     )
Ejemplo n.º 4
0
def p_expression_unary(p):
    """expression : MINUS expression
                  | NOT expression
    """
    p[0] = tq_ast.UnaryOperator(p[1], p[2])
Ejemplo n.º 5
0
def p_expression_is_not_null(p):
    """expression : expression IS NOT NULL"""
    p[0] = tq_ast.UnaryOperator('is_not_null', p[1])