File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
test/data/multiple_changelogs/changelogs/1.2.4 Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 55from psycopg .errors import SyntaxError
66
77from pum .exceptions import PumSqlException
8+ import re
89
910logger = logging .getLogger (__name__ )
1011
@@ -40,7 +41,20 @@ def execute_sql(
4041 sql_code = sql_content
4142 else :
4243 sql_code = sql_content
43- sql_code = sql_code .split (";" )
44+ def split_sql_statements (sql ):
45+ pattern = r'(?:[^;\'"]|\'[^\']*\'|"[^"]*")*;'
46+ matches = re .finditer (pattern , sql , re .DOTALL )
47+ statements = []
48+ last_end = 0
49+ for match in matches :
50+ end = match .end ()
51+ statements .append (sql [last_end :end - 1 ].strip ())
52+ last_end = end
53+ if last_end < len (sql ):
54+ statements .append (sql [last_end :].strip ())
55+ return [stmt for stmt in statements if stmt ]
56+
57+ sql_code = split_sql_statements (sql_code )
4458 else :
4559 sql_code = [sql ]
4660
Original file line number Diff line number Diff line change 11
22ALTER TABLE pum_test_data .some_table RENAME COLUMN created_date TO created;
3- COMMENT ON COLUMN pum_test_data.some_table.created IS ' A comment with quotes ' ' and a backslash \\ ' ;
3+ COMMENT ON COLUMN pum_test_data.some_table.created IS ' A comment with semi column; , quotes ' ' and a backslash \\ ' ;
You can’t perform that action at this time.
0 commit comments