Пример #1
0
 def test_left_outer_join(self):
     self.assert_parsed_select(
         'SELECT t1.foo, t2.bar '
         'FROM table1 t1 LEFT OUTER JOIN EACH table2 t2 ON t1.id = t2.id',
         tq_ast.Select(
             [
                 tq_ast.SelectField(tq_ast.ColumnId('t1.foo'), None, None),
                 tq_ast.SelectField(tq_ast.ColumnId('t2.bar'), None, None)
             ],
             tq_ast.Join(tq_ast.TableId('table1', 't1'), [
                 tq_ast.PartialJoin(
                     tq_ast.TableId('table2', 't2'),
                     tq_ast.JoinType.LEFT_OUTER,
                     tq_ast.BinaryOperator('=', tq_ast.ColumnId('t1.id'),
                                           tq_ast.ColumnId('t2.id')),
                 ),
             ]), None, None, None, None, None, None))
     self.assert_parsed_select(
         'SELECT t1.foo, t2.bar '
         'FROM table1 t1 LEFT JOIN table2 t2 ON t1.id = t2.id',
         tq_ast.Select(
             [
                 tq_ast.SelectField(tq_ast.ColumnId('t1.foo'), None, None),
                 tq_ast.SelectField(tq_ast.ColumnId('t2.bar'), None, None)
             ],
             tq_ast.Join(tq_ast.TableId('table1', 't1'), [
                 tq_ast.PartialJoin(
                     tq_ast.TableId('table2', 't2'),
                     tq_ast.JoinType.LEFT_OUTER,
                     tq_ast.BinaryOperator('=', tq_ast.ColumnId('t1.id'),
                                           tq_ast.ColumnId('t2.id')),
                 ),
             ]), None, None, None, None, None, None))
Пример #2
0
def p_table_expr_left_outer_join(p):
    """full_table_expr : aliased_table_expr LEFT OUTER JOIN \
                         aliased_table_expr ON expression
                       | aliased_table_expr LEFT OUTER JOIN EACH \
                         aliased_table_expr ON expression
    """
    p[0] = tq_ast.Join(p[1], p[len(p) - 3], p[len(p) - 1], is_left_outer=True)
Пример #3
0
def p_table_expr_join(p):
    """full_table_expr : aliased_table_expr JOIN aliased_table_expr \
                            ON expression
                       | aliased_table_expr JOIN EACH aliased_table_expr \
                            ON expression
    """
    p[0] = tq_ast.Join(p[1], p[len(p) - 3], p[len(p) - 1], is_left_outer=False)
Пример #4
0
 def test_cross_join(self):
     self.assert_parsed_select(
         'SELECT 0 FROM table1 t1 CROSS JOIN table2 t2',
         tq_ast.Select(
             [tq_ast.SelectField(tq_ast.Literal(0), None, None)],
             tq_ast.Join(tq_ast.TableId('table1', 't1'), [
                 tq_ast.PartialJoin(tq_ast.TableId('table2', 't2'),
                                    tq_ast.JoinType.CROSS, None),
             ]), None, None, None, None, None, None))
Пример #5
0
 def test_join_each(self):
     self.assert_parsed_select(
         'SELECT 0 FROM table1 t1 JOIN EACH table2 t2 ON t1.foo = t2.bar',
         tq_ast.Select([tq_ast.SelectField(tq_ast.Literal(0), None)],
                       tq_ast.Join(tq_ast.TableId('table1', 't1'),
                                   tq_ast.TableId('table2', 't2'),
                                   tq_ast.BinaryOperator(
                                       '=', tq_ast.ColumnId('t1.foo'),
                                       tq_ast.ColumnId('t2.bar')),
                                   is_left_outer=False), None, None, None,
                       None, None))
Пример #6
0
def p_join(p):
    """full_table_expr : aliased_table_expr join_tail"""
    p[0] = tq_ast.Join(p[1], p[2])