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)
| 570 | |
| 571 | |
| 572 | def _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 | ) |
no outgoing calls
no test coverage detected