Beispiel #1
0
 def test_multi_part_join(self):
     self.assert_parsed_select(
         'SELECT t1.foo, t2.bar, t3.baz '
         'FROM table1 t1 LEFT OUTER JOIN EACH table2 t2 ON t1.id = t2.id '
         'JOIN table3 t3 ON t3.id = t1.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.SelectField(tq_ast.ColumnId('t3.baz'), 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')),
                 ),
                 tq_ast.PartialJoin(
                     tq_ast.TableId('table3', 't3'),
                     tq_ast.JoinType.INNER,
                     tq_ast.BinaryOperator('=', tq_ast.ColumnId('t3.id'),
                                           tq_ast.ColumnId('t1.id')),
                 ),
             ]), None, None, None, None, None, None))
Beispiel #2
0
def p_partial_join(p):
    """partial_join : non_cross_join aliased_table_expr ON expression
                    | cross_join aliased_table_expr
    """
    if p[1] is tq_ast.JoinType.CROSS:
        p[0] = tq_ast.PartialJoin(p[2], p[1], None)
    else:
        p[0] = tq_ast.PartialJoin(p[2], p[1], p[4])
Beispiel #3
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))
Beispiel #4
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, None)],
             tq_ast.Join(tq_ast.TableId('table1', 't1'), [
                 tq_ast.PartialJoin(
                     tq_ast.TableId('table2', 't2'),
                     tq_ast.JoinType.INNER,
                     tq_ast.BinaryOperator('=', tq_ast.ColumnId('t1.foo'),
                                           tq_ast.ColumnId('t2.bar')),
                 ),
             ]), None, None, None, None, None, None))