Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support comments in statements in JdbcTestUtils
Prior to this commit, executing an SQL script with JdbcTestUtils would fail if a statement in the script contained a line comment within the statement. This commit ensures that standard SQL comments (i.e., any text beginning with two hyphens and extending to the end of the line) are properly omitted from the statement before executing it. In addition, multiple adjacent whitespace characters within a statement but outside a literal are now collapsed into a single space. Issue: SPR-9982
- Loading branch information
Showing
3 changed files
with
65 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 11 additions & 1 deletion
12
spring-test/src/test/resources/org/springframework/test/jdbc/test-data-with-comments.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,16 @@ | ||
-- 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 orders(id, order_date, customer_id) values (1, '2008-01-02', 2); | ||
INSERT INTO persons( person_id-- | ||
, name) | ||
VALUES( 1 -- person_id | ||
, 'Name' --name | ||
);-- |