Strips comments from a SQL statement, does a simple test first to avoid always instantiating the expensive ParsedQuery constructor This is useful for engines that don't support comments :param statement: A string with the SQL statement :return: SQL statement without comments
(statement: str)
| 66 | |
| 67 | |
| 68 | def strip_comments_from_sql(statement: str) -> str: |
| 69 | """ |
| 70 | Strips comments from a SQL statement, does a simple test first |
| 71 | to avoid always instantiating the expensive ParsedQuery constructor |
| 72 | |
| 73 | This is useful for engines that don't support comments |
| 74 | |
| 75 | :param statement: A string with the SQL statement |
| 76 | :return: SQL statement without comments |
| 77 | """ |
| 78 | return ParsedQuery(statement).strip_comments() if "--" in statement else statement |
| 79 | |
| 80 | |
| 81 | @dataclass(eq=True, frozen=True) |