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

Function _allow_join_condition

pgcli/packages/sqlcompletion.py:552–569  ·  view source on GitHub ↗

Tests if a join condition should be suggested We need this to avoid bad suggestions when entering e.g. select * from tbl1 a join tbl2 b on a.id = So check that the preceding token is a ON, AND, or OR keyword, instead of e.g. an equals sign. :param statement: a

(statement)

Source from the content-addressed store, hash-verified

550
551
552def _allow_join_condition(statement):
553 """
554 Tests if a join condition should be suggested
555
556 We need this to avoid bad suggestions when entering e.g.
557 select * from tbl1 a join tbl2 b on a.id = <cursor>
558 So check that the preceding token is a ON, AND, or OR keyword, instead of
559 e.g. an equals sign.
560
561 :param statement: an sqlparse.sql.Statement
562 :return: boolean
563 """
564
565 if not statement or not statement.tokens:
566 return False
567
568 last_tok = statement.token_prev(len(statement.tokens))[1]
569 return last_tok.value.lower() in ("on", "and", "or")
570
571
572def _allow_join(statement):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected