Accept functions and paths with reserved words (string expressions) in EQL IN expressions.

Closes #3834
This commit is contained in:
Mark Paluch
2025-04-09 15:30:19 +02:00
parent e101ce4440
commit ac4c6e6b9c
6 changed files with 12 additions and 8 deletions

View File

@@ -349,7 +349,7 @@ between_expression
;
in_expression
: (state_valued_path_expression | type_discriminator) (NOT)? IN (('(' in_item (',' in_item)* ')') | ( '(' subquery ')') | collection_valued_input_parameter)
: (string_expression | type_discriminator) (NOT)? IN (('(' in_item (',' in_item)* ')') | ( '(' subquery ')') | collection_valued_input_parameter)
;
in_item

View File

@@ -333,7 +333,7 @@ between_expression
;
in_expression
: (state_valued_path_expression | type_discriminator) (NOT)? IN (('(' in_item (',' in_item)* ')') | ( '(' subquery ')') | collection_valued_input_parameter)
: (string_expression | type_discriminator) (NOT)? IN (('(' in_item (',' in_item)* ')') | ( '(' subquery ')') | collection_valued_input_parameter)
;
in_item

View File

@@ -1228,8 +1228,8 @@ class EqlQueryRenderer extends EqlBaseVisitor<List<JpaQueryParsingToken>> {
List<JpaQueryParsingToken> tokens = new ArrayList<>();
if (ctx.state_valued_path_expression() != null) {
tokens.addAll(visit(ctx.state_valued_path_expression()));
if (ctx.string_expression() != null) {
tokens.addAll(visit(ctx.string_expression()));
}
if (ctx.type_discriminator() != null) {
tokens.addAll(visit(ctx.type_discriminator()));

View File

@@ -1149,8 +1149,8 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<List<JpaQueryParsingToken>> {
List<JpaQueryParsingToken> tokens = new ArrayList<>();
if (ctx.state_valued_path_expression() != null) {
tokens.addAll(visit(ctx.state_valued_path_expression()));
if (ctx.string_expression() != null) {
tokens.addAll(visit(ctx.string_expression()));
}
if (ctx.type_discriminator() != null) {
tokens.addAll(visit(ctx.type_discriminator()));

View File

@@ -37,6 +37,7 @@ import org.junit.jupiter.params.provider.ValueSource;
*
* @author Greg Turnquist
* @author Christoph Strobl
* @author Mark Paluch
*/
class EqlQueryRendererTests {
@@ -1032,12 +1033,14 @@ class EqlQueryRendererTests {
assertQuery("select te from TestEntity te where te.lateral = :lateral");
}
@Test
@Test // GH-3834
void reservedWordsShouldWork() {
assertQuery("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId");
assertQuery("select ie.object from ItemExample ie left join ie.object io where io.externalId = :externalId");
assertQuery("select ie from ItemExample ie left join ie.object io where io.object = :externalId");
assertQuery("select ie from ItemExample ie where ie.status = com.app.domain.object.Status.UP");
assertQuery("select f from FooEntity f where upper(f.name) IN :names");
assertQuery("select f from FooEntity f where f.size IN :sizes");
}
}

View File

@@ -37,6 +37,7 @@ import org.junit.jupiter.params.provider.ValueSource;
*
* @author Greg Turnquist
* @author Christoph Strobl
* @author Mark Paluch
* @since 3.1
*/
class JpqlQueryRendererTests {
@@ -1033,7 +1034,7 @@ class JpqlQueryRendererTests {
assertQuery(source);
}
@Test
@Test // GH-3834
void reservedWordsShouldWork() {
assertQuery("select ie from ItemExample ie left join ie.object io where io.externalId = :externalId");