Fix: issue#2845 SqlUtil.formatSql 格式化的sql换行异常

This commit is contained in:
LeonemZhang 2023-08-04 11:20:31 +08:00
parent 0621543ae3
commit ec1e13d3b1
2 changed files with 13 additions and 0 deletions

View File

@ -110,6 +110,12 @@ public class SqlFormatter {
t = this.tokens.nextToken();
this.token += t;
} while (!"\"".equals(t));
} else if ("`".equals(this.token)) {
String t;
do {
t = this.tokens.nextToken();
this.token += t;
} while (!"`".equals(t));
}
if ((this.afterByOrSetOrFromOrSelect) && (",".equals(this.token))) {

View File

@ -11,4 +11,11 @@ public class SqlFormatterTest {
String sql = "(select 1 from dual) union all (select 1 from dual)";
SqlFormatter.format(sql);
}
@Test
public void testKeyword() {
String sql = "select * from `order`";
String format = SqlFormatter.format(sql);
System.out.println(format);
}
}