Determines if the statement is a database switch such as 'use' or '\\u'. When a database is changed the existing completions must be reset before we start the completion refresh for the new database.
(queries: str)
| 452 | |
| 453 | |
| 454 | def need_completion_reset(queries: str) -> bool: |
| 455 | """Determines if the statement is a database switch such as 'use' or '\\u'. |
| 456 | When a database is changed the existing completions must be reset before we |
| 457 | start the completion refresh for the new database. |
| 458 | """ |
| 459 | for query in sqlparse.split(queries): |
| 460 | try: |
| 461 | tokens = query.split() |
| 462 | first_token = tokens[0] |
| 463 | if first_token.lower() in ("use", "/use", "\\u", "/u"): |
| 464 | return True |
| 465 | if first_token.lower() in ("\\r", "/r", "connect", "/connect") and len(tokens) > 1: |
| 466 | return True |
| 467 | except Exception: |
| 468 | continue |
| 469 | return False |
| 470 | |
| 471 | |
| 472 | def is_mutating(status_plain: str | None) -> bool: |