(self, full_text, text_before_cursor)
| 50 | |
| 51 | class SqlStatement: |
| 52 | def __init__(self, full_text, text_before_cursor): |
| 53 | self.identifier = None |
| 54 | self.word_before_cursor = word_before_cursor = last_word(text_before_cursor, include="many_punctuations") |
| 55 | full_text = _strip_named_query(full_text) |
| 56 | text_before_cursor = _strip_named_query(text_before_cursor) |
| 57 | |
| 58 | full_text, text_before_cursor, self.local_tables = isolate_query_ctes(full_text, text_before_cursor) |
| 59 | |
| 60 | self.text_before_cursor_including_last_word = text_before_cursor |
| 61 | |
| 62 | # If we've partially typed a word then word_before_cursor won't be an |
| 63 | # empty string. In that case we want to remove the partially typed |
| 64 | # string before sending it to the sqlparser. Otherwise the last token |
| 65 | # will always be the partially typed string which renders the smart |
| 66 | # completion useless because it will always return the list of |
| 67 | # keywords as completion. |
| 68 | if self.word_before_cursor: |
| 69 | if word_before_cursor[-1] == "(" or word_before_cursor[0] == "\\": |
| 70 | parsed = sqlparse.parse(text_before_cursor) |
| 71 | else: |
| 72 | text_before_cursor = text_before_cursor[: -len(word_before_cursor)] |
| 73 | parsed = sqlparse.parse(text_before_cursor) |
| 74 | self.identifier = parse_partial_identifier(word_before_cursor) |
| 75 | else: |
| 76 | parsed = sqlparse.parse(text_before_cursor) |
| 77 | |
| 78 | full_text, text_before_cursor, parsed = _split_multiple_statements(full_text, text_before_cursor, parsed) |
| 79 | |
| 80 | self.full_text = full_text |
| 81 | self.text_before_cursor = text_before_cursor |
| 82 | self.parsed = parsed |
| 83 | |
| 84 | self.last_token = parsed and parsed.token_prev(len(parsed.tokens))[1] or "" |
| 85 | |
| 86 | def is_insert(self): |
| 87 | return self.parsed.token_first().value.lower() == "insert" |
nothing calls this directly
no test coverage detected