Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
15 commits
Select commit Hold shift + click to select a range
e85b148
Refactor subquery detection logic in JpqlQueryRenderer
polyglot-k Sep 25, 2025
a5960e7
Add author annotation to JpqlQueryRendererTests
polyglot-k Sep 25, 2025
3dd2631
Add author annotation to JpqlQueryRenderer and remove from tests
polyglot-k Sep 25, 2025
59dc33b
Add author annotation to EqlQueryRenderer and refactor subquery detec…
polyglot-k Sep 26, 2025
ea1dc95
Add author annotation to HqlQueryRenderer and refactor subquery and s…
polyglot-k Sep 26, 2025
17f7ce9
Update author annotation in JpqlQueryRenderer and refactor isSetQuery…
polyglot-k Sep 26, 2025
7e9cb50
Refactor isSetQuery method in EqlQueryRenderer, HqlQueryRenderer, and…
polyglot-k Sep 26, 2025
4232500
Refactor isSetQuery method in HqlQueryRenderer for improved readability
polyglot-k Sep 26, 2025
3a92ca8
Refactor isSetQuery method in HqlQueryRenderer for improved readability
polyglot-k Sep 26, 2025
a42045f
Refactor isSetQuery method in HqlQueryRenderer for improved readability
polyglot-k Sep 26, 2025
a58181c
Refactor isSetQuery method in HqlQueryRenderer for improved readability
polyglot-k Sep 26, 2025
4100222
Refactor isSubquery and isSetQuery methods in EqlQueryRenderer for im…
polyglot-k Sep 26, 2025
9a6b0da
Refactor isSubquery and isSetQuery methods in HqlQueryRenderer for im…
polyglot-k Sep 26, 2025
68468a0
Refactor isSubquery and isSetQuery methods in JpqlQueryRenderer for i…
polyglot-k Sep 26, 2025
8a6094b
Refactor isSubquery and isSetQuery methods in EqlQueryRenderer and Hq…
polyglot-k Sep 26, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -32,6 +32,7 @@
/**
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders an EQL query without making any changes.
*
* @author TaeHyun Kang(polyglot-k)
* @author Greg Turnquist
* @author Christoph Strobl
* @author Mark Paluch
Expand All @@ -47,15 +48,16 @@ class EqlQueryRenderer extends EqlBaseVisitor<QueryTokenStream> {
*/
static boolean isSubquery(ParserRuleContext ctx) {

if (ctx instanceof EqlParser.SubqueryContext) {
return true;
} else if (ctx instanceof EqlParser.Update_statementContext) {
return false;
} else if (ctx instanceof EqlParser.Delete_statementContext) {
return false;
} else {
return ctx.getParent() != null && isSubquery(ctx.getParent());
while (ctx != null) {
if (ctx instanceof EqlParser.SubqueryContext) {
return true;
}
if (ctx instanceof EqlParser.Update_statementContext || ctx instanceof EqlParser.Delete_statementContext) {
return false;
}
ctx = ctx.getParent();
}
return false;
}

/**
Expand All @@ -65,11 +67,13 @@ static boolean isSubquery(ParserRuleContext ctx) {
*/
static boolean isSetQuery(ParserRuleContext ctx) {

if (ctx instanceof EqlParser.Set_fuctionContext) {
return true;
while (ctx != null) {
if (ctx instanceof EqlParser.Set_fuctionContext) {
return true;
}
ctx = ctx.getParent();
}

return ctx.getParent() != null && isSetQuery(ctx.getParent());
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -32,6 +32,7 @@
/**
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders an HQL query without making any changes.
*
* @author TaeHyun Kang(polyglot-k)
* @author Greg Turnquist
* @author Christoph Strobl
* @author Oscar Fanchin
Expand All @@ -48,19 +49,20 @@ class HqlQueryRenderer extends HqlBaseVisitor<QueryTokenStream> {
*/
static boolean isSubquery(ParserRuleContext ctx) {

if (ctx instanceof HqlParser.SubqueryContext || ctx instanceof HqlParser.CteContext) {
return true;
} else if (ctx instanceof HqlParser.SelectStatementContext) {
return false;
} else if (ctx instanceof HqlParser.InsertStatementContext) {
return false;
} else if (ctx instanceof HqlParser.DeleteStatementContext) {
return false;
} else if (ctx instanceof HqlParser.UpdateStatementContext) {
return false;
} else {
return ctx.getParent() != null && isSubquery(ctx.getParent());
while (ctx != null) {
if (ctx instanceof HqlParser.SubqueryContext || ctx instanceof HqlParser.CteContext) {
return true;
}
if (ctx instanceof HqlParser.SelectStatementContext ||
ctx instanceof HqlParser.InsertStatementContext ||
ctx instanceof HqlParser.DeleteStatementContext ||
ctx instanceof HqlParser.UpdateStatementContext
) {
return false;
}
ctx = ctx.getParent();
}
return false;
}

/**
Expand All @@ -70,14 +72,16 @@ static boolean isSubquery(ParserRuleContext ctx) {
*/
static boolean isSetQuery(ParserRuleContext ctx) {

if (ctx instanceof HqlParser.OrderedQueryContext
&& ctx.getParent() instanceof HqlParser.QueryExpressionContext qec) {
if (qec.orderedQuery().indexOf(ctx) != 0) {
return true;
while (ctx != null) {
ParserRuleContext parent = ctx.getParent();
if (ctx instanceof HqlParser.OrderedQueryContext && parent instanceof HqlParser.QueryExpressionContext qec) {
if (qec.orderedQuery().indexOf(ctx) != 0) {
return true;
}
}
ctx = parent;
}

return ctx.getParent() != null && isSetQuery(ctx.getParent());
return false;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Expand All @@ -32,6 +32,7 @@
/**
* An ANTLR {@link org.antlr.v4.runtime.tree.ParseTreeVisitor} that renders a JPQL query without making any changes.
*
* @author TaeHyun Kang(polyglot-k)
* @author Greg Turnquist
* @author Christoph Strobl
* @author Mark Paluch
Expand All @@ -47,15 +48,16 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<QueryTokenStream> {
*/
static boolean isSubquery(ParserRuleContext ctx) {

if (ctx instanceof JpqlParser.SubqueryContext) {
return true;
} else if (ctx instanceof JpqlParser.Update_statementContext) {
return false;
} else if (ctx instanceof JpqlParser.Delete_statementContext) {
return false;
} else {
return ctx.getParent() != null && isSubquery(ctx.getParent());
while (ctx != null) {
if (ctx instanceof JpqlParser.SubqueryContext) {
return true;
}
if (ctx instanceof JpqlParser.Update_statementContext || ctx instanceof JpqlParser.Delete_statementContext) {
return false;
}
ctx = ctx.getParent();
}
return false;
}

/**
Expand All @@ -65,11 +67,13 @@ static boolean isSubquery(ParserRuleContext ctx) {
*/
static boolean isSetQuery(ParserRuleContext ctx) {

if (ctx instanceof JpqlParser.Set_fuctionContext) {
return true;
while (ctx != null) {
if (ctx instanceof JpqlParser.Set_fuctionContext) {
return true;
}
ctx = ctx.getParent();
}

return ctx.getParent() != null && isSetQuery(ctx.getParent());
return false;
}

@Override
Expand Down