How to use the pgcli.packages.sqlcompletion.Table 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_suggest_qualified_aliasable_tables_and_views(expression):
    suggestions = suggest_type(expression, expression)
    assert set(suggestions) == set([Table(schema="sch"), View(schema="sch")])
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_function_arguments_with_alias_given():
    suggestions = suggest_type("SELECT avg(x. FROM tbl x, tbl2 y", "SELECT avg(x.")

    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"),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
                Table(schema="t1"),
                View(schema="t1"),
                Column(table_refs=((None, "tabl1", "t1", False),)),
                Function(schema="t1"),
            ],
        ),
    ],
)
def test_named_query_completion(text, before, expected):
    suggestions = suggest_type(text, before)
    assert set(expected) == set(suggestions)
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 / tests / test_sqlcompletion.py View on Github external
def test_suggest_qualified_tables_and_views(expression):
    suggestions = suggest_type(expression, expression)
    assert set(suggestions) == set([Table(schema="sch"), View(schema="sch")])
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_sqlcompletion.py View on Github external
def test_drop_schema_qualified_table_suggests_only_tables():
    text = "DROP TABLE schema_name.table_name"
    suggestions = suggest_type(text, text)
    assert suggestions == (Table(schema="schema_name"),)