How to use the pgcli.packages.sqlcompletion.Function function in pgcli

To help you get started, we’ve selected a few pgcli examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
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),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_col_comma_suggests_cols():
    suggestions = suggest_type("SELECT a, b, FROM tbl", "SELECT a, b,")
    assert set(suggestions) == set(
        [
            Column(table_refs=((None, "tbl", None, False),), qualifiable=True),
            Function(schema=None),
            Keyword("SELECT"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_sub_select_col_name_completion():
    suggestions = suggest_type(
        "SELECT * FROM (SELECT  FROM abc", "SELECT * FROM (SELECT "
    )
    assert set(suggestions) == set(
        [
            Column(table_refs=((None, "abc", None, False),), qualifiable=True),
            Function(schema=None),
            Keyword("SELECT"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_dot_suggests_cols_of_a_table_or_schema_qualified_table():
    suggestions = suggest_type("SELECT tabl. FROM tabl", "SELECT tabl.")
    assert set(suggestions) == set(
        [
            Column(table_refs=((None, "tabl", None, False),)),
            Table(schema="tabl"),
            View(schema="tabl"),
            Function(schema="tabl"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_statements_in_function_body(text):
    suggestions = suggest_type(text, text[: text.find("  ") + 1])
    assert set(suggestions) == set(
        [
            Column(table_refs=((None, "foo", None, False),), qualifiable=True),
            Function(schema=None),
            Keyword("SELECT"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_dot_col_comma_suggests_cols_or_schema_qualified_table():
    suggestions = suggest_type(
        "SELECT t1.a, t2. FROM tabl1 t1, tabl2 t2", "SELECT t1.a, t2."
    )
    assert set(suggestions) == set(
        [
            Column(table_refs=((None, "tabl2", "t2", False),)),
            Table(schema="t2"),
            View(schema="t2"),
            Function(schema="t2"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_join_alias_dot_suggests_cols2(sql):
    suggestion = suggest_type(sql, sql)
    assert set(suggestion) == set(
        [
            Column(table_refs=((None, "def", "d", False),)),
            Table(schema="d"),
            View(schema="d"),
            Function(schema="d"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_distinct_suggests_cols(text):
    suggestions = suggest_type(text, text)
    assert set(suggestions) == set(
        [
            Column(table_refs=(), local_tables=(), qualifiable=True),
            Function(schema=None),
            Keyword("DISTINCT"),
        ]
github dbcli / pgcli / pgcli / pgcompleter.py View on Github external
def get_from_clause_item_matches(self, suggestion, word_before_cursor):
        alias = self.generate_aliases
        s = suggestion
        t_sug = Table(s.schema, s.table_refs, s.local_tables)
        v_sug = View(s.schema, s.table_refs)
        f_sug = Function(s.schema, s.table_refs, usage="from")
        return (
            self.get_table_matches(t_sug, word_before_cursor, alias)
            + self.get_view_matches(v_sug, word_before_cursor, alias)
            + self.get_function_matches(f_sug, word_before_cursor, alias)
        )