def test_suggest_qualified_tables_views_functions_and_joins(expression):
    suggestions = suggest_type(expression, expression)
    tbls = tuple([(None, 'foo', None, False)])
    assert set(suggestions) == set([
        FromClauseItem(schema='sch', table_refs=tbls),
        Join(tbls, 'sch'),
    ])
def test_suggest_after_join_with_one_table(expression):
    suggestions = suggest_type(expression, expression)
    tables = ((None, 'foo', None, False), )
    assert set(suggestions) == set([
        FromClauseItem(schema=None, table_refs=tables),
        Join(((None, 'foo', None, False), ), None),
        Schema(),
    ])
def test_suggest_after_join_with_two_tables(expression):
    suggestions = suggest_type(expression, expression)
    tables = tuple([(None, 'foo', None, False), (None, 'bar', None, False)])
    assert set(suggestions) == set([
        FromClauseItem(schema=None, table_refs=tables),
        Join(tables, None),
        Schema(),
    ])
def test_join_suggests_tables_and_schemas(tbl_alias, join_type):
    text = 'SELECT * FROM abc {0} {1} JOIN '.format(tbl_alias, join_type)
    suggestion = suggest_type(text, text)
    tbls = tuple([(None, 'abc', tbl_alias or None, False)])
    assert set(suggestion) == set([
        FromClauseItem(schema=None, table_refs=tbls),
        Schema(),
        Join(tbls, None),
    ])
示例#5
0
 def test_suggest_after_join_with_one_table():
     expressions = ['SELECT * FROM foo JOIN ', 'SELECT * FROM foo JOIN bar']
     for expression in expressions:
         suggestions = suggest_type(expression, expression)
         tables = ((None, 'foo', None, False), )
         assert set(suggestions) == set([
             FromClauseItem(schema=None, table_refs=tables),
             Join(((None, 'foo', None, False), ), None),
             Schema(),
         ])
示例#6
0
 def test_suggest_qualified_tables_views_functions_and_joins(self):
     expressions = [
         'SELECT * FROM foo JOIN sch.'
     ]
     for expression in expressions:
         suggestions = suggest_type(expression, expression)
         tbls = tuple([(None, 'foo', None, False)])
         assert set(suggestions) == set([
             FromClauseItem(schema='sch', table_refs=tbls),
             Join(tbls, 'sch'),
         ])
示例#7
0
 def test_join_suggests_tables_and_schemas():
     join_types = ('', 'INNER', 'LEFT', 'RIGHT OUTER',)
     tbl_aliases = ('', 'foo',)
     for join_type in join_types:
         for tbl_alias in tbl_aliases:
             text = 'SELECT * FROM abc {0} {1} JOIN '.format(tbl_alias, join_type)
             suggestion = suggest_type(text, text)
             tbls = tuple([(None, 'abc', tbl_alias or None, False)])
             assert set(suggestion) == set([
                 FromClauseItem(schema=None, table_refs=tbls),
                 Schema(),
                 Join(tbls, None),
             ])
示例#8
0
 def test_suggest_after_join_with_two_tables():
     expressions = [
         'SELECT * FROM foo JOIN bar on bar.barid = foo.barid JOIN ',
         'SELECT * FROM foo JOIN bar USING (barid) JOIN '
     ]
     for expression in expressions:
         suggestions = suggest_type(expression, expression)
         tables = tuple([(None, 'foo', None, False), (None, 'bar', None, False)])
         assert set(suggestions) == set([
             FromClauseItem(schema=None, table_refs=tables),
             Join(tables, None),
             Schema(),
         ])