Support multi-line comments in SQL scripts
Prior to this commit neither ResourceDatabasePopulator nor JdbcTestUtils properly supported multi-line comments (e.g., /* ... */). Secondarily there has developed a significant amount of code duplication in these two classes that has led to maintenance issues over the years. This commit addresses these issues as follows: - Common code has been extracted from ResourceDatabasePopulator and JdbcTestUtils and moved to a new ScriptUtils class in the spring-jdbc module. - Relevant test cases have been migrated from JdbcTestUtilsTests to ScriptUtilsTests. - ScriptUtils.splitSqlScript() has been modified to ignore multi-line comments in scripts during processing. - ResourceDatabasePopulator supports configuration of the start and end delimiters for multi-line (block) comments. - A new test case was added to ScriptUtilsTests for the new multi-line comment support. Issue: SPR-9531
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
-- The next comment line starts with a tab.
|
||||
-- x, y, z...
|
||||
|
||||
insert into customer (id, name)
|
||||
values (1, 'Sam Brannen');
|
||||
-- This is also a comment with a leading tab.
|
||||
insert into orders(id, order_date, customer_id) values (1, '2013-06-08', 1);
|
||||
-- This is also a comment with a leading tab, a space, and a tab.
|
||||
insert into orders(id, order_date, customer_id) values (2, '2013-06-08', 1);
|
||||
@@ -1,16 +0,0 @@
|
||||
-- The next comment line has no text after the '--' prefix.
|
||||
--
|
||||
-- The next comment line starts with a space.
|
||||
-- x, y, z...
|
||||
|
||||
insert into customer (id, name)
|
||||
values (1, 'Rod; Johnson'), (2, 'Adrian Collier');
|
||||
-- This is also a comment.
|
||||
insert into orders(id, order_date, customer_id)
|
||||
values (1, '2008-01-02', 2);
|
||||
insert into orders(id, order_date, customer_id) values (1, '2008-01-02', 2);
|
||||
INSERT INTO persons( person_id--
|
||||
, name)
|
||||
VALUES( 1 -- person_id
|
||||
, 'Name' --name
|
||||
);--
|
||||
Reference in New Issue
Block a user