File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -26,6 +26,13 @@ def _split_queries(sql: str) -> List[str]:
2626
2727 Handles semicolons inside strings and comments.
2828 """
29+ def has_sql_content (text : str ) -> bool :
30+ """Check if text has actual SQL content (not just comments/whitespace)."""
31+ # Strip comments
32+ no_block_comments = re .sub (r"/\*.*?\*/" , "" , text , flags = re .DOTALL )
33+ no_comments = re .sub (r"--[^\n]*" , "" , no_block_comments )
34+ return bool (no_comments .strip ())
35+
2936 queries = []
3037 current = []
3138 in_single_quote = False
@@ -81,7 +88,8 @@ def _split_queries(sql: str) -> List[str]:
8188 if char == ';' and not in_single_quote and not in_double_quote :
8289 current .append (char )
8390 query = '' .join (current ).strip ()
84- if query and query != ';' :
91+ # Only add if it has actual SQL content (not just comments)
92+ if query and query != ';' and has_sql_content (query ):
8593 queries .append (query )
8694 current = []
8795 i += 1
@@ -92,7 +100,8 @@ def _split_queries(sql: str) -> List[str]:
92100
93101 # Handle last query (might not end with semicolon)
94102 remaining = '' .join (current ).strip ()
95- if remaining :
103+ # Only add if it has actual SQL content (not just comments)
104+ if remaining and has_sql_content (remaining ):
96105 queries .append (remaining )
97106
98107 return queries
You can’t perform that action at this time.
0 commit comments