mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
解决 SQLExprParser.SQLParser union all 前面直接包含子查询 解析异常
This commit is contained in:
@@ -362,8 +362,6 @@ public class SQLExprParser extends SQLParser {
|
||||
if (sqlExpr instanceof SQLBinaryOpExpr) {
|
||||
((SQLBinaryOpExpr) sqlExpr).setBracket(true);
|
||||
}
|
||||
|
||||
accept(Token.RPAREN);
|
||||
|
||||
if (lexer.token == Token.UNION && sqlExpr instanceof SQLQueryExpr) {
|
||||
SQLQueryExpr queryExpr = (SQLQueryExpr) sqlExpr;
|
||||
@@ -371,6 +369,13 @@ public class SQLExprParser extends SQLParser {
|
||||
SQLSelectQuery query = this.createSelectParser().queryRest(queryExpr.getSubQuery().getQuery());
|
||||
queryExpr.getSubQuery().setQuery(query);
|
||||
}
|
||||
|
||||
//accept(Token.RPAREN) 在处理UNION 之前,导致 以下类型的语句解析异常
|
||||
//select * from test_a where id=(select id from test_b where id = 1) union all select * from test_c .....
|
||||
//会解析为 select * from select * from test_a where id=(select id from test_b where id = 1 union all select * from test_c .....
|
||||
//所以需要将accept(Token.RPAREN) 移动到 处理 Union all 以及 子查询之后
|
||||
accept(Token.RPAREN);
|
||||
|
||||
break;
|
||||
case INSERT:
|
||||
lexer.nextToken();
|
||||
|
||||
Reference in New Issue
Block a user