Exemplo n.º 1
0
 def test_multi_clause_case(self):
     self.assert_parsed_select(
         'SELECT CASE WHEN x = 4 THEN 16 WHEN x = 5 THEN 25 END',
         tq_ast.Select(
             [
                 tq_ast.SelectField(
                     tq_ast.CaseExpression([
                         tq_ast.CaseClause(
                             tq_ast.BinaryOperator('=',
                                                   tq_ast.ColumnId('x'),
                                                   tq_ast.Literal(4)),
                             tq_ast.Literal(16)
                         ),
                         tq_ast.CaseClause(
                             tq_ast.BinaryOperator('=',
                                                   tq_ast.ColumnId('x'),
                                                   tq_ast.Literal(5)),
                             tq_ast.Literal(25)
                         ),
                     ]),
                     None
                 )
             ],
             None, None, None, None, None, None
         )
     )
Exemplo n.º 2
0
def p_expression_case(p):
    """expression : CASE case_body END"""
    p[0] = tq_ast.CaseExpression(p[2])