Skip to content

Commit

Permalink
修复SQLUtils的toSQLString在VisitorFeature.OutputNameQuote模式下,会将Mysql的TIME…
Browse files Browse the repository at this point in the history
…STAMPDIFF和TIMESTAMPADD第一个unit参数当作字段添加``问题 #5309
  • Loading branch information
AdolphLv authored and wenshao committed Jul 9, 2023
1 parent e766f53 commit bf4e78e
Showing 1 changed file with 9 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1923,6 +1923,7 @@ public boolean visit(SQLMethodInvokeExpr x) {

protected void printMethodParameters(SQLMethodInvokeExpr x) {
String function = x.getMethodName();
long nameHashCode64 = x.methodNameHashCode64();
List<SQLExpr> parameters = x.getArguments();

print('(');
Expand Down Expand Up @@ -1971,6 +1972,14 @@ protected void printMethodParameters(SQLMethodInvokeExpr x) {
}
}

if (i == 0 && (nameHashCode64 == FnvHash.Constants.TIMESTAMPDIFF || nameHashCode64 == FnvHash.Constants.TIMESTAMPADD)
&& param instanceof SQLIdentifierExpr) {
if (DbType.mysql == dbType) {
print(((SQLIdentifierExpr) param).getName());
continue;
}
}

printExpr(param, parameterized);
}

Expand Down

0 comments on commit bf4e78e

Please sign in to comment.