Exemplo n.º 1
0
 def cols_etc(table, schema=None, alias=None, is_function=False, parent=None, \
             last_keyword=None):
     """Returns the expected select-clause suggestions for a single-table
     select."""
     #pylint: disable=too-many-arguments
     return set([
         Column(table_refs=(TableReference(schema, table, alias, is_function),), \
             qualifiable=True),
         Function(schema=parent),
         Keyword(last_keyword)
     ])
Exemplo n.º 2
0
    def test_distinct_and_order_by_suggestions_with_alias_given():
        test_args = [('SELECT DISTINCT x. FROM tbl x JOIN tbl1 y',
                      'SELECT DISTINCT x.'),
                     ('SELECT * FROM tbl x JOIN tbl1 y ORDER BY x.',
                      'SELECT * FROM tbl x JOIN tbl1 y ORDER BY x.')]
        for arg in test_args:
            text = arg[0]
            text_before = arg[1]

            suggestions = suggest_type(text, text_before)
            assert set(suggestions) == set([
                Column(table_refs=(TableReference(None, 'tbl', 'x', False), ),
                       local_tables=(),
                       qualifiable=False),
                Table(schema='x'),
                View(schema='x'),
                Function(schema='x'),
            ])
 def addcols(schema, rel, alias, reltype, cols):
     tbl = TableReference(schema, rel, alias, reltype == 'functions')
     if tbl not in columns:
         columns[tbl] = []
     columns[tbl].extend(cols)