Skip to content

Commit 5153895

Browse files
committed
fixes #117 UNDO statement without a line break is ignored.
1 parent 5249b7e commit 5153895

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/main/java/org/apache/ibatis/migration/MigrationReader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public int read(char[] cbuf, int off, int len) throws IOException {
9595
while (buffer.length() == 0) {
9696
int result = in.read(cbuf, off, len);
9797
if (result == -1) {
98-
if (lineBuffer.length() > 0 && !undo && !inUndo) {
98+
if (lineBuffer.length() > 0 && (!undo || inUndo)) {
9999
buffer.append(lineBuffer).append(lineSeparator);
100100
lineBuffer.setLength(0);
101101
}

src/test/java/org/apache/ibatis/migration/MigrationReaderTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,19 @@ public void shouldReturnUndoPart() throws Exception {
7272
// @formatter:on
7373
}
7474

75+
@Test
76+
public void shouldReturnUndoPart_NoEndBreak() throws Exception {
77+
// @formatter:off
78+
String script = "-- comment\n"
79+
+ "do part\n"
80+
+ "--//@UNDO\n"
81+
+ "undo part";
82+
String result = readAsString(new MigrationReader(strToInputStream(script, charset), charset, true, null));
83+
assertEquals("-- @UNDO\n"
84+
+ "undo part\n", result);
85+
// @formatter:on
86+
}
87+
7588
@Test
7689
public void shouldUndoCommentBeLenient() throws Exception {
7790
// @formatter:off

0 commit comments

Comments
 (0)