Ejemplo n.º 1
0
 def test_on_suggests_tables_and_join_conditions_right_side():
     sqls = [
         'select abc.x, bcd.y from abc join bcd on abc.id = bcd.id and ',
         'select abc.x, bcd.y from abc join bcd on ',
     ]
     for sql in sqls:
         suggestions = suggest_type(sql, sql)
         tables = ((None, 'abc', None, False), (None, 'bcd', None, False))
         assert set(suggestions) == set((JoinCondition(table_refs=tables, parent=None), \
             Alias(aliases=('abc', 'bcd',)),))
Ejemplo n.º 2
0
def test_join_alias_dot_suggests_cols1(sql):
    suggestions = suggest_type(sql, sql)
    tables = ((None, 'abc', 'a', False), (None, 'def', 'd', False))
    assert set(suggestions) == set([
        Column(table_refs=((None, 'abc', 'a', False), )),
        Table(schema='a'),
        View(schema='a'),
        Function(schema='a'),
        JoinCondition(table_refs=tables, parent=(None, 'abc', 'a', False))
    ])
Ejemplo n.º 3
0
def test_on_suggests_tables_and_join_conditions_right_side(sql):
    suggestions = suggest_type(sql, sql)
    tables = ((None, 'abc', None, False), (None, 'bcd', None, False))
    assert set(suggestions) == set((
        JoinCondition(table_refs=tables, parent=None),
        Alias(aliases=(
            'abc',
            'bcd',
        )),
    ))
Ejemplo n.º 4
0
 def test_join_alias_dot_suggests_cols1():
     sqls = [
         'SELECT * FROM abc a JOIN def d ON a.',
         'SELECT * FROM abc a JOIN def d ON a.id = d.id AND a.',
     ]
     for sql in sqls:
         suggestions = suggest_type(sql, sql)
         tables = ((None, 'abc', 'a', False), (None, 'def', 'd', False))
         assert set(suggestions) == set([
             Column(table_refs=((None, 'abc', 'a', False),)),
             Table(schema='a'),
             View(schema='a'),
             Function(schema='a'),
             JoinCondition(table_refs=tables, parent=(None, 'abc', 'a', False))
         ])
Ejemplo n.º 5
0
    def test_on_suggests_aliases_and_join_conditions():
        sqls = [ \
'select a.x, b.y from abc a join bcd b on ',
        '''select a.x, b.y
from abc a
join bcd b on
''',
        '''select a.x, b.y
from abc a
join bcd b
on ''',
        'select a.x, b.y from abc a join bcd b on a.id = b.id OR ' \
        ]
        for sql in sqls:
            suggestions = suggest_type(sql, sql)
            tables = ((None, 'abc', 'a', False), (None, 'bcd', 'b', False))
            assert set(suggestions) == set((JoinCondition(table_refs=tables, parent=None), \
                Alias(aliases=('a', 'b',)),))