Returns True if any of the queries in *queries* is destructive.
(keywords: list[str], queries: str)
| 384 | |
| 385 | |
| 386 | def is_destructive(keywords: list[str], queries: str) -> bool: |
| 387 | """Returns True if any of the queries in *queries* is destructive.""" |
| 388 | for query in sqlparse.split(queries): |
| 389 | if not query: |
| 390 | continue |
| 391 | # subtle: if "UPDATE" is one of our keywords AND "query" starts with "UPDATE" |
| 392 | if query_starts_with(query, keywords) and query_starts_with(query, ["update"]): |
| 393 | if query_has_where_clause(query) and query_is_single_table_update(query): |
| 394 | return False |
| 395 | else: |
| 396 | return True |
| 397 | if query_starts_with(query, keywords): |
| 398 | return True |
| 399 | |
| 400 | return False |
| 401 | |
| 402 | |
| 403 | def is_dropping_database(queries: str, dbname: str | None) -> bool: |