bugfix of mysql parser for #comment

This commit is contained in:
Yako
2014-08-28 21:06:55 +08:00
parent 31ddfe45fb
commit 3007078dbb
2 changed files with 15 additions and 1 deletions
@@ -29,4 +29,14 @@ public class SQLUtilsTest extends TestCase {
String sql = "begin\n" + " if (a=10) then\n" + " null;\n" + " else\n" + " null;\n" + " end if;\n" + "end;";
System.out.println(SQLUtils.formatOracle(sql));
}
public void test_format_3() throws Exception {
String sql = "select lottery_notice_issue,lottery_notice_date,lottery_notice_result from tb_lottery_notice where lottery_type_id=8 and lottery_notice_issue<=2014066 UNION ALL SELECT NULL, NULL, NULL, NULL, NULL, NULL# and lottery_notice_issue>=2014062 order by lottery_notice_issue desc";
String formattedSql = SQLUtils.formatMySql(sql);
String expected = "SELECT lottery_notice_issue, lottery_notice_date, lottery_notice_result"
+ "\nFROM tb_lottery_notice" + "\nWHERE lottery_type_id = 8"
+ "\n\tAND lottery_notice_issue <= 2014066" + "\nUNION ALL"
+ "\nSELECT NULL, NULL, NULL, NULL, NULL" + "\n\t, NULL";
Assert.assertEquals(expected, formattedSql);
}
}