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)
| 550 | |
| 551 | |
| 552 | def _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 | |
| 572 | def _allow_join(statement): |
no outgoing calls
no test coverage detected