Accept functions and paths with reserved words (string expressions) in EQL IN expressions.
Closes #3834
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -337,7 +337,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
|
||||
|
||||
@@ -1155,8 +1155,8 @@ class EqlQueryRenderer extends EqlBaseVisitor<QueryTokenStream> {
|
||||
|
||||
QueryRendererBuilder builder = QueryRenderer.builder();
|
||||
|
||||
if (ctx.state_valued_path_expression() != null) {
|
||||
builder.append(visit(ctx.state_valued_path_expression()));
|
||||
if (ctx.string_expression() != null) {
|
||||
builder.append(visit(ctx.string_expression()));
|
||||
}
|
||||
if (ctx.type_discriminator() != null) {
|
||||
builder.append(visit(ctx.type_discriminator()));
|
||||
|
||||
@@ -1078,8 +1078,8 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<QueryTokenStream> {
|
||||
|
||||
QueryRendererBuilder builder = QueryRenderer.builder();
|
||||
|
||||
if (ctx.state_valued_path_expression() != null) {
|
||||
builder.appendExpression(visit(ctx.state_valued_path_expression()));
|
||||
if (ctx.string_expression() != null) {
|
||||
builder.appendExpression(visit(ctx.string_expression()));
|
||||
}
|
||||
if (ctx.type_discriminator() != null) {
|
||||
builder.appendExpression(visit(ctx.type_discriminator()));
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.data.jpa.repository.query.QueryRenderer.TokenRenderer
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
class EqlQueryRendererTests {
|
||||
|
||||
@@ -1041,12 +1042,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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.springframework.data.jpa.repository.query.QueryRenderer.TokenRenderer
|
||||
*
|
||||
* @author Greg Turnquist
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
* @since 3.1
|
||||
*/
|
||||
class JpqlQueryRendererTests {
|
||||
@@ -1027,7 +1028,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");
|
||||
|
||||
Reference in New Issue
Block a user