MCPcopy
hub / github.com/dbcli/pgcli / _suggest_expression

Function _suggest_expression

pgcli/packages/sqlcompletion.py:522–543  ·  view source on GitHub ↗

Return suggestions for an expression, taking account of any partially-typed identifier's parent, which may be a table alias or schema name.

(token_v, stmt)

Source from the content-addressed store, hash-verified

520
521
522def _suggest_expression(token_v, stmt):
523 """
524 Return suggestions for an expression, taking account of any partially-typed
525 identifier's parent, which may be a table alias or schema name.
526 """
527 parent = stmt.identifier.get_parent_name() if stmt.identifier else []
528 tables = stmt.get_tables()
529
530 if parent:
531 tables = tuple(t for t in tables if identifies(parent, t))
532 return (
533 Column(table_refs=tables, local_tables=stmt.local_tables),
534 Table(schema=parent),
535 View(schema=parent),
536 Function(schema=parent),
537 )
538
539 return (
540 Column(table_refs=tables, local_tables=stmt.local_tables, qualifiable=True),
541 Function(schema=None),
542 Keyword(token_v.upper()),
543 )
544
545
546def identifies(table_id, ref):

Callers 1

Calls 2

identifiesFunction · 0.85
get_tablesMethod · 0.80

Tested by

no test coverage detected