mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix format bug
This commit is contained in:
@@ -615,6 +615,15 @@ public class SqlBuilder implements Builder<String> {
|
||||
return this.paramValues.toArray(new Object[0]);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化SQL语句
|
||||
* @return SqlBuilder
|
||||
*/
|
||||
public SqlBuilder format() {
|
||||
this.sql.replace(0, this.sql.length(), SqlFormatter.format(this.sql.toString()));
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建,默认打印SQL日志
|
||||
*
|
||||
|
@@ -122,6 +122,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))) {
|
||||
@@ -320,7 +326,7 @@ public class SqlFormatter {
|
||||
}
|
||||
|
||||
private static boolean isFunctionName(final String tok) {
|
||||
if(StrUtil.isEmpty(tok)){
|
||||
if (StrUtil.isEmpty(tok)) {
|
||||
return true;
|
||||
}
|
||||
final char begin = tok.charAt(0);
|
||||
|
Reference in New Issue
Block a user