How to use the pgcli.packages.parseutils.tables.TableReference 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_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),
        ]
github dbcli / pgcli / tests / test_sqlcompletion.py View on Github external
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"),
        ]
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
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),
        ]
github dbcli / pgcli / pgcli / pgcompleter.py View on Github external
def addcols(schema, rel, alias, reltype, cols):
            tbl = TableReference(schema, rel, alias, reltype == "functions")
            if tbl not in columns:
                columns[tbl] = []
            columns[tbl].extend(cols)