mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
fix #4486
This commit is contained in:
@@ -1077,11 +1077,11 @@ public class SQLSelectParser extends SQLParser {
|
||||
|| lexer.token == Token.SEL) {
|
||||
SQLSelect select = select();
|
||||
accept(Token.RPAREN);
|
||||
if (select.getQuery() instanceof SQLSelectQueryBlock) {
|
||||
((SQLSelectQueryBlock) select.getQuery()).setParenthesized(true);
|
||||
}
|
||||
SQLSelectQuery selectQuery = select.getQuery();
|
||||
selectQuery.setParenthesized(true);
|
||||
|
||||
SQLSelectQuery query = queryRest(select.getQuery(), true);
|
||||
boolean acceptUnion = !(selectQuery instanceof SQLUnionQuery);
|
||||
SQLSelectQuery query = queryRest(selectQuery, acceptUnion);
|
||||
if (query instanceof SQLUnionQuery) {
|
||||
tableSource = new SQLUnionQueryTableSource((SQLUnionQuery) query);
|
||||
} else {
|
||||
|
||||
@@ -13,4 +13,30 @@ from (
|
||||
union
|
||||
select id, collectId, c2
|
||||
from (select id, collectId, c2 from table_2)
|
||||
)
|
||||
)
|
||||
---------------------------
|
||||
SELECT *
|
||||
FROM (
|
||||
SELECT id, collectId, 3 AS c_0
|
||||
FROM (
|
||||
SELECT *
|
||||
FROM tc_merchant
|
||||
WHERE collectId IN (
|
||||
SELECT collect_id
|
||||
FROM cte_merchant
|
||||
)
|
||||
UNION
|
||||
SELECT *
|
||||
FROM st_merchant
|
||||
WHERE collectId IN (
|
||||
SELECT collect_id
|
||||
FROM st_merchant_tmp
|
||||
)
|
||||
)
|
||||
UNION
|
||||
SELECT id, collectId, c2
|
||||
FROM (
|
||||
SELECT id, collectId, c2
|
||||
FROM table_2
|
||||
)
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user