Skip to content

Commit

Permalink
fixes #117 UNDO statement without a line break is ignored.
Browse files Browse the repository at this point in the history
  • Loading branch information
harawata committed Mar 20, 2018
1 parent 5249b7e commit 5153895
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public int read(char[] cbuf, int off, int len) throws IOException {
while (buffer.length() == 0) {
int result = in.read(cbuf, off, len);
if (result == -1) {
if (lineBuffer.length() > 0 && !undo && !inUndo) {
if (lineBuffer.length() > 0 && (!undo || inUndo)) {
buffer.append(lineBuffer).append(lineSeparator);
lineBuffer.setLength(0);
}
Expand Down
13 changes: 13 additions & 0 deletions src/test/java/org/apache/ibatis/migration/MigrationReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,19 @@ public void shouldReturnUndoPart() throws Exception {
// @formatter:on
}

@Test
public void shouldReturnUndoPart_NoEndBreak() throws Exception {
// @formatter:off
String script = "-- comment\n"
+ "do part\n"
+ "--//@UNDO\n"
+ "undo part";
String result = readAsString(new MigrationReader(strToInputStream(script, charset), charset, true, null));
assertEquals("-- @UNDO\n"
+ "undo part\n", result);
// @formatter:on
}

@Test
public void shouldUndoCommentBeLenient() throws Exception {
// @formatter:off
Expand Down

0 comments on commit 5153895

Please sign in to comment.