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 ) )
def p_case_clause_when(p): """case_clause_when : WHEN expression THEN expression""" p[0] = tq_ast.CaseClause(p[2], p[4])
def p_case_clause_else(p): """case_clause_else : ELSE expression""" p[0] = tq_ast.CaseClause(tq_ast.Literal(True), p[2])