Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,9 @@ public List getSqlStatements(JdbcMigrationContext context, String sqlStatements)
case '-':
case '/':
if (!inQuotedString && i + 1 < sqlChars.length
&& sqlChars[i + 1] == sqlChars[i])
&& sqlChars[i + 1] == sqlChars[i]
&& !isStoredProcedure(context.getDatabaseType().getDatabaseType(),
currentStatement.toString()))
{
inComment = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -327,4 +327,23 @@ public void testSybasePatchesCommitsOnEveryStatement() throws IOException,
connectionControl.verify();
}

/**
* Tests that comments in stored procedures aren't stripped
*
* @throws IOException
* if an unexpected error occurs.
*/
public void testCommentsPreservedInStoredProcedures() throws IOException
{
InputStream is = getClass().getResourceAsStream("test/stored_procedure.sql");
assertNotNull(is);
task = new SqlScriptMigrationTask("stored_procedure.sql", 1, is);

MockDatabaseType dbType = new MockDatabaseType("mysql");
dbType.setMultipleStatementsSupported(false);
context.setDatabaseType(dbType);
List statements = task.getSqlStatements(context);
assertEquals(1, statements.size());
assertTrue(statements.get(0).toString().contains("-- test comment"));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
CREATE PROCEDURE TEST_PROC()
BEGIN
DECLARE V_TEST INTEGER;
-- test comment
SELECT C1 INTO V_TEST FROM(VALUES(0));
END