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)
| 533 | |
| 534 | |
| 535 | def _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 | |
| 555 | def _allow_join(statement): |
no outgoing calls
no test coverage detected