How to use the pgcli.packages.sqlcompletion.View 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 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_sub_select_dot_col_name_completion():
    suggestions = suggest_type(
        "SELECT * FROM (SELECT t. FROM tabl t", "SELECT * FROM (SELECT t."
    )
    assert set(suggestions) == set(
        [
            Column(table_refs=((None, "tabl", "t", False),)),
            Table(schema="t"),
            View(schema="t"),
            Function(schema="t"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_dot_suggests_cols_of_an_alias_where(sql):
    suggestions = suggest_type(sql, sql)
    assert set(suggestions) == set(
        [
            Table(schema="t1"),
            View(schema="t1"),
            Column(table_refs=((None, "tabl1", "t1", False),)),
            Function(schema="t1"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
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)),
        ]
github dbcli / pgcli / tests / test_pgspecial.py View on Github external
def test_d_dot_suggests_schema_qualified_tables_or_views():
    suggestions = suggest_type("\d myschema.", "\d myschema.")
    assert set(suggestions) == set([Table(schema="myschema"), View(schema="myschema")])

    suggestions = suggest_type("\d myschema.xxx", "\d myschema.xxx")
    assert set(suggestions) == set([Table(schema="myschema"), View(schema="myschema")])
github dbcli / pgcli / tests / test_pgspecial.py View on Github external
def test_d_suggests_tables_views_and_schemas():
    suggestions = suggest_type("\d ", "\d ")
    assert set(suggestions) == set([Schema(), Table(schema=None), View(schema=None)])

    suggestions = suggest_type("\d xxx", "\d xxx")
    assert set(suggestions) == set([Schema(), Table(schema=None), View(schema=None)])
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_suggests_tables_views_and_schemas(expression):
    suggestions = suggest_type(expression, expression)
    assert set(suggestions) == set([Table(schema=None), View(schema=None), Schema()])
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_dot_suggests_cols_of_an_alias(sql):
    suggestions = suggest_type(sql, "SELECT t1.")
    assert set(suggestions) == set(
        [
            Table(schema="t1"),
            View(schema="t1"),
            Column(table_refs=((None, "tabl1", "t1", False),)),
            Function(schema="t1"),
        ]
github dbcli / pgcli / pgcli / pgcompleter.py View on Github external
def get_namedquery_matches(self, _, word_before_cursor):
        return self.find_matches(
            word_before_cursor, NamedQueries.instance.list(), meta="named query"
        )

    suggestion_matchers = {
        FromClauseItem: get_from_clause_item_matches,
        JoinCondition: get_join_condition_matches,
        Join: get_join_matches,
        Column: get_column_matches,
        Function: get_function_matches,
        Schema: get_schema_matches,
        Table: get_table_matches,
        TableFormat: get_table_formats,
        View: get_view_matches,
        Alias: get_alias_matches,
        Database: get_database_matches,
        Keyword: get_keyword_matches,
        Special: get_special_matches,
        Datatype: get_datatype_matches,
        NamedQuery: get_namedquery_matches,
        Path: get_path_matches,
    }

    def populate_scoped_cols(self, scoped_tbls, local_tbls=()):
        """Find all columns in a set of scoped_tables.

        :param scoped_tbls: list of TableReference namedtuples
        :param local_tbls: tuple(TableMetadata)
        :return: {TableReference:{colname:ColumnMetaData}}