Merge "script: strip comments in SQL statements"
This commit is contained in:
commit
24521798bc
@ -281,6 +281,16 @@ class TestSqlScript(fixture.Pathed, fixture.DB):
|
||||
for script_pattern in (
|
||||
"BEGIN TRANSACTION; %s; COMMIT;",
|
||||
"BEGIN; %s; END TRANSACTION;",
|
||||
"/* comment */BEGIN TRANSACTION; %s; /* comment */COMMIT;",
|
||||
"/* comment */ BEGIN TRANSACTION; %s; /* comment */ COMMIT;",
|
||||
"""
|
||||
-- comment
|
||||
BEGIN TRANSACTION;
|
||||
|
||||
%s;
|
||||
|
||||
-- comment
|
||||
COMMIT;""",
|
||||
):
|
||||
|
||||
test_statement = ("CREATE TABLE TEST1 (field1 int); "
|
||||
|
@ -54,6 +54,7 @@ class SqlScript(base.BaseScript):
|
||||
# not all drivers reliably handle multistatement queries or
|
||||
# commands passed to .execute(), so split them and execute one
|
||||
# by one
|
||||
text = sqlparse.format(text, strip_comments=True, strip_whitespace=True)
|
||||
for statement in sqlparse.split(text):
|
||||
if statement:
|
||||
if re.match(ignored_regex, statement):
|
||||
|
Loading…
Reference in New Issue
Block a user