Support comments in statements in RDbPopulator

Prior to this commit, executing an SQL script via
ResourceDatabasePopulator 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-10075
This commit is contained in:
Sam Brannen
2012-12-05 17:41:24 +01:00
parent d0f687f028
commit aa16caa2ac
3 changed files with 75 additions and 37 deletions

View File

@@ -0,0 +1,12 @@
-- The next comment line has no text after the '--' prefix.
--
-- The next comment line starts with a space.
-- x, y, z...
INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller');
-- This is also a comment.
INSERT INTO
users(first_name, last_name)
VALUES( 'Sam' -- first_name
, 'Brannen' -- last_name
);--