File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed
resources/script_file_tests Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -352,7 +352,11 @@ def split_sql_script(
352352 logger .info ("Splitting script file into statements..." )
353353 statements_to_execute = []
354354 if external_parser :
355- statements_to_execute = sqlparse .split (sql_file .read ())
355+ split_statements = sqlparse .split (sql_file .read ())
356+ for statement in split_statements :
357+ statement_without_comments = sqlparse .format (statement , strip_comments = True )
358+ if statement_without_comments :
359+ statements_to_execute .append (statement_without_comments )
356360 else :
357361 current_statement = ""
358362 inside_statements_group = False
Original file line number Diff line number Diff line change 1+ -- here is a comment
2+ SELECT * FROM person;
3+ -- here is some another comment
4+ -- on more lines
5+ SELECT * FROM person WHERE id= 1 ;
6+ --
Original file line number Diff line number Diff line change @@ -57,6 +57,17 @@ Split Script Into Statements - External Parser
5757 ${results } = Query ${command }
5858 END
5959
60+ Split Script Into Statements - External Parser - Comments Are Removed
61+ Insert Data In Person Table Using SQL Script
62+ @{Expected commands } = Create List
63+ ... SELECT * FROM person;
64+ ... SELECT * FROM person WHERE id=1;
65+ ${extracted commands } = Split Sql Script ${Script files dir } /split_commands_comments.sql external_parser=True
66+ Lists Should Be Equal ${Expected commands } ${extracted commands }
67+ FOR ${command } IN @{extracted commands }
68+ ${results } = Query ${command }
69+ END
70+
6071
6172*** Keywords ***
6273Run SQL Script File
You can’t perform that action at this time.
0 commit comments