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

Function _allow_join

pgcli/packages/sqlcompletion.py:572–591  ·  view source on GitHub ↗

Tests if a join should be suggested We need this to avoid bad suggestions when entering e.g. select * from tbl1 a join tbl2 b So check that the preceding token is a JOIN keyword :param statement: an sqlparse.sql.Statement :return: boolean

(statement)

Source from the content-addressed store, hash-verified

570
571
572def _allow_join(statement):
573 """
574 Tests if a join should be suggested
575
576 We need this to avoid bad suggestions when entering e.g.
577 select * from tbl1 a join tbl2 b <cursor>
578 So check that the preceding token is a JOIN keyword
579
580 :param statement: an sqlparse.sql.Statement
581 :return: boolean
582 """
583
584 if not statement or not statement.tokens:
585 return False
586
587 last_tok = statement.token_prev(len(statement.tokens))[1]
588 return last_tok.value.lower().endswith("join") and last_tok.value.lower() not in (
589 "cross join",
590 "natural join",
591 )

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected