Skip to content

Commit a67023f

Browse files
lingo-xpwenshao
authored andcommitted
Support inSubQuery quota replacement.
1 parent 978f805 commit a67023f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

core/src/main/java/com/alibaba/druid/sql/visitor/SQLASTOutputVisitor.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4927,7 +4927,12 @@ public boolean visit(SQLAllExpr x) {
49274927

49284928
@Override
49294929
public boolean visit(SQLInSubQueryExpr x) {
4930-
x.getExpr().accept(this);
4930+
if (x.getExpr() instanceof SQLIdentifierExpr) {
4931+
String columnName = replaceQuota(((SQLIdentifierExpr) x.getExpr()).getName());
4932+
printName0(columnName);
4933+
} else {
4934+
x.getExpr().accept(this);
4935+
}
49314936
if (x.isNot()) {
49324937
if (x.isGlobal()) {
49334938
print0(ucase ? " GLOBAL NOT IN (" : " global not in (");

core/src/test/resources/bvt/parser/sqlserver/0.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
select * from [test].[test] where [a] in (select [c] from [test])
2+
--------------------
3+
SELECT *
4+
FROM [test].[test]
5+
WHERE [a] IN (
6+
SELECT [c]
7+
FROM [test]
8+
)
9+
------------------------------------------------------------------------------------------------------------------------
110
select * from [test].[test]
211
--------------------
312
SELECT *

0 commit comments

Comments
 (0)