MCPcopy Create free account
hub / github.com/dbcli/mssql-cli / _allow_join_condition

Function _allow_join_condition

mssqlcli/packages/sqlcompletion.py:535–552  ·  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

533
534
535def _allow_join_condition(statement):
536 """
537 Tests if a join condition should be suggested
538
539 We need this to avoid bad suggestions when entering e.g.
540 select * from tbl1 a join tbl2 b on a.id = <cursor>
541 So check that the preceding token is a ON, AND, or OR keyword, instead of
542 e.g. an equals sign.
543
544 :param statement: an sqlparse.sql.Statement
545 :return: boolean
546 """
547
548 if not statement or not statement.tokens:
549 return False
550
551 last_tok = statement.token_prev(len(statement.tokens))[1]
552 return last_tok.value.lower() in ('on', 'and', 'or')
553
554
555def _allow_join(statement):

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected