druid SQLUtils.refactor修改表别名出错

8wtpewkr  于 2022-11-02  发布在  Druid
关注(0)|答案(1)|浏览(251)

Map<String, String> tableAliasMap =new HashMap<String, String>();
tableAliasMap.put("a", "u");
System.out.println(SQLUtils.refactor("a.username","mysql", tableAliasMap));
数据库类型mysql、odps报错,oracle成功
报错:
com.alibaba.druid.sql.parser.ParserException: syntax error, error in :'a.username', expect IDENTIFIER, actual IDENTIFIER pos 1, line 1, column 2, token IDENTIFIER a
at com.alibaba.druid.sql.parser.SQLParser.printError(SQLParser.java:287)
at com.alibaba.druid.sql.parser.SQLStatementParser.parseStatementList(SQLStatementParser.java:532)

guykilcj

guykilcj1#

解决方法:修改类SQLStatementParser的parseStatementList方法
public void parseStatementList(List statementList, int max, SQLObject parent) {
添加 case IDENTIFIER: {
String strVal = lexer.stringVal();

相关问题