Merge branch '5.1.x'

This commit is contained in:
Juergen Hoeller
2019-02-08 18:16:27 +01:00
10 changed files with 84 additions and 58 deletions

View File

@@ -162,6 +162,20 @@ public class ScriptUtilsUnitTests {
assertEquals("statement 2 not split correctly", statement2, statements.get(1));
}
@Test
public void readAndSplitScriptContainingMultiLineNestedComments() throws Exception {
String script = readScript("test-data-with-multi-line-nested-comments.sql");
List<String> statements = new ArrayList<>();
splitSqlScript(script, ';', statements);
String statement1 = "INSERT INTO users(first_name, last_name) VALUES('Juergen', 'Hoeller')";
String statement2 = "INSERT INTO users(first_name, last_name) VALUES( 'Sam' , 'Brannen' )";
assertEquals("wrong number of statements", 2, statements.size());
assertEquals("statement 1 not split correctly", statement1, statements.get(0));
assertEquals("statement 2 not split correctly", statement2, statements.get(1));
}
@Test
public void containsDelimiters() {
assertFalse(containsSqlScriptDelimiters("select 1\n select ';'", ";"));

View File

@@ -0,0 +1,23 @@
/* This is a multi line comment
* The next comment line has no text
* 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.
/*-------------------------------------------
-- A fancy multi-line comments that puts
-- single line comments inside of a multi-line
-- comment block.
Moreover, the block commend end delimiter
appears on a line that can potentially also
be a single-line comment if we weren't
already inside a multi-line comment run.
-------------------------------------------*/
INSERT INTO
users(first_name, last_name) -- This is a single line comment containing the block-end-comment sequence here */ but it's still a single-line comment
VALUES( 'Sam' -- first_name
, 'Brannen' -- last_name
);--