How to use the pgcli.packages.sqlcompletion.Column 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_insert_into_lparen_comma_suggests_cols():
    suggestions = suggest_type("INSERT INTO abc (id,", "INSERT INTO abc (id,")
    assert suggestions == (
        Column(table_refs=((None, "abc", None, False),), context="insert"),
    )
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_handle_unrecognized_kw_generously():
    sql = "SELECT * FROM sessions WHERE session = 1 AND "
    suggestions = suggest_type(sql, sql)
    expected = Column(table_refs=((None, "sessions", None, False),), qualifiable=True)

    assert expected in set(suggestions)
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
                Column(table_refs=(), qualifiable=True),
                Function(schema=None),
                Keyword("SELECT"),
            ],
        ),
        ("\\ns abc SELECT foo ", "SELECT foo ", (Keyword(),)),
        (
            "\\ns abc SELECT t1. FROM tabl1 t1",
            "SELECT t1.",
            [
                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_columns_after_multiple_joins():
    sql = """select * from t1
            inner join t2 ON
              t1.id = t2.t1_id
            inner join t3 ON
              t2.id = t3."""
    suggestions = suggest_type(sql, sql)
    assert Column(table_refs=((None, "t3", None, False),)) in set(suggestions)
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_column_keyword_suggests_columns(sql):
    suggestions = suggest_type(sql, sql)
    assert set(suggestions) == set([Column(table_refs=((None, "foo", None, False),))])
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
def test_insert_into_lparen_partial_text_suggests_cols():
    suggestions = suggest_type("INSERT INTO abc (i", "INSERT INTO abc (i")
    assert suggestions == (
        Column(table_refs=((None, "abc", None, False),), context="insert"),
    )
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_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"),
        ]