def test_distinct_and_order_by_suggestions_with_aliases( text, text_before, last_keyword): suggestions = suggest_type(text, text_before) assert set(suggestions) == set([ Column(table_refs=( TableReference(None, 'tbl', 'x', False), TableReference(None, 'tbl1', 'y', False), ), local_tables=(), qualifiable=True), Function(schema=None), Keyword(last_keyword) ])
def cols_etc(table, schema=None, alias=None, is_function=False, parent=None): return set([ Column(table_refs=(TableReference(schema, table, alias, is_function), ), qualifiable=True), Function(schema=parent), Keyword() ])
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.""" return set([ Column(table_refs=(TableReference(schema, table, alias, is_function),), qualifiable=True), Function(schema=parent), Keyword(last_keyword)])
def test_distinct_and_order_by_suggestions_with_alias_given(text, text_before): 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 test_function_arguments_with_alias_given(): suggestions = suggest_type("SELECT avg(x. FROM tbl x, tbl2 y", "SELECT avg(x.") assert set(suggestions) == { Column( table_refs=(TableReference(None, "tbl", "x", False),), local_tables=(), qualifiable=False, ), Table(schema="x"), View(schema="x"), Function(schema="x"), }