Skip to content

Commit 59dc33b

Browse files
committed
Add author annotation to EqlQueryRenderer and refactor subquery detection logic
Signed-off-by: KNU-K <[email protected]>
1 parent 3dd2631 commit 59dc33b

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/EqlQueryRenderer.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
/**
3333
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders an EQL query without making any changes.
3434
*
35+
* @author TaeHyun Kang(polyglot-k)
3536
* @author Greg Turnquist
3637
* @author Christoph Strobl
3738
* @author Mark Paluch
@@ -47,15 +48,16 @@ class EqlQueryRenderer extends EqlBaseVisitor<QueryTokenStream> {
4748
*/
4849
static boolean isSubquery(ParserRuleContext ctx) {
4950

50-
if (ctx instanceof EqlParser.SubqueryContext) {
51-
return true;
52-
} else if (ctx instanceof EqlParser.Update_statementContext) {
53-
return false;
54-
} else if (ctx instanceof EqlParser.Delete_statementContext) {
55-
return false;
56-
} else {
57-
return ctx.getParent() != null && isSubquery(ctx.getParent());
58-
}
51+
while (ctx != null) {
52+
if (ctx instanceof EqlParser.SubqueryContext) {
53+
return true;
54+
}
55+
if (ctx instanceof EqlParser.Update_statementContext || ctx instanceof EqlParser.Delete_statementContext) {
56+
return false;
57+
}
58+
ctx = ctx.getParent();
59+
}
60+
return false;
5961
}
6062

6163
/**
@@ -65,11 +67,13 @@ static boolean isSubquery(ParserRuleContext ctx) {
6567
*/
6668
static boolean isSetQuery(ParserRuleContext ctx) {
6769

68-
if (ctx instanceof EqlParser.Set_fuctionContext) {
69-
return true;
70-
}
71-
72-
return ctx.getParent() != null && isSetQuery(ctx.getParent());
70+
while (ctx != null) {
71+
if (ctx instanceof EqlParser.Set_fuctionContext) {
72+
return true;
73+
}
74+
ctx = ctx.getParent();
75+
}
76+
return false;
7377
}
7478

7579
@Override

0 commit comments

Comments
 (0)