Fix parsing of EQL/JPQL using string literals and enums in IN items.
Closes #3835
This commit is contained in:
@@ -354,7 +354,12 @@ in_expression
|
||||
|
||||
in_item
|
||||
: literal
|
||||
| string_expression
|
||||
| boolean_literal
|
||||
| numeric_literal
|
||||
| date_time_timestamp_literal
|
||||
| single_valued_input_parameter
|
||||
| conditional_expression
|
||||
;
|
||||
|
||||
like_expression
|
||||
|
||||
@@ -338,7 +338,12 @@ in_expression
|
||||
|
||||
in_item
|
||||
: literal
|
||||
| string_expression
|
||||
| boolean_literal
|
||||
| numeric_literal
|
||||
| date_time_timestamp_literal
|
||||
| single_valued_input_parameter
|
||||
| conditional_expression
|
||||
;
|
||||
|
||||
like_expression
|
||||
|
||||
@@ -1270,15 +1270,23 @@ class EqlQueryRenderer extends EqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
@Override
|
||||
public List<JpaQueryParsingToken> visitIn_item(EqlParser.In_itemContext ctx) {
|
||||
|
||||
List<JpaQueryParsingToken> tokens = new ArrayList<>();
|
||||
|
||||
if (ctx.literal() != null) {
|
||||
tokens.addAll(visit(ctx.literal()));
|
||||
return visit(ctx.literal());
|
||||
} else if (ctx.string_expression() != null) {
|
||||
return visit(ctx.string_expression());
|
||||
} else if (ctx.boolean_literal() != null) {
|
||||
return visit(ctx.boolean_literal());
|
||||
} else if (ctx.numeric_literal() != null) {
|
||||
return visit(ctx.numeric_literal());
|
||||
} else if (ctx.date_time_timestamp_literal() != null) {
|
||||
return visit(ctx.date_time_timestamp_literal());
|
||||
} else if (ctx.single_valued_input_parameter() != null) {
|
||||
tokens.addAll(visit(ctx.single_valued_input_parameter()));
|
||||
return visit(ctx.single_valued_input_parameter());
|
||||
} else if (ctx.conditional_expression() != null) {
|
||||
return visit(ctx.conditional_expression());
|
||||
}
|
||||
|
||||
return tokens;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1191,15 +1191,24 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
@Override
|
||||
public List<JpaQueryParsingToken> visitIn_item(JpqlParser.In_itemContext ctx) {
|
||||
|
||||
List<JpaQueryParsingToken> tokens = new ArrayList<>();
|
||||
|
||||
if (ctx.literal() != null) {
|
||||
tokens.addAll(visit(ctx.literal()));
|
||||
return visit(ctx.literal());
|
||||
} else if (ctx.string_expression() != null) {
|
||||
return visit(ctx.string_expression());
|
||||
} else if (ctx.boolean_literal() != null) {
|
||||
return visit(ctx.boolean_literal());
|
||||
} else if (ctx.numeric_literal() != null) {
|
||||
return visit(ctx.numeric_literal());
|
||||
} else if (ctx.date_time_timestamp_literal() != null) {
|
||||
return visit(ctx.date_time_timestamp_literal());
|
||||
} else if (ctx.single_valued_input_parameter() != null) {
|
||||
tokens.addAll(visit(ctx.single_valued_input_parameter()));
|
||||
return visit(ctx.single_valued_input_parameter());
|
||||
} else if (ctx.conditional_expression() != null) {
|
||||
return visit(ctx.conditional_expression());
|
||||
}
|
||||
|
||||
return tokens;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -561,6 +561,18 @@ class EqlQueryRendererTests {
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void inClauseWithFunctionAndLiterals() {
|
||||
|
||||
assertQuery("""
|
||||
select f from FooEntity f where upper(f.name) IN ('Y', 'Basic', 'Remit')
|
||||
""");
|
||||
assertQuery(
|
||||
"""
|
||||
select count(f) from FooEntity f where f.status IN (com.example.eql_bug_check.entity.FooStatus.FOO, com.example.eql_bug_check.entity.FooStatus.BAR)
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void notEqualsForTypeShouldWork() {
|
||||
|
||||
|
||||
@@ -562,6 +562,18 @@ class JpqlQueryRendererTests {
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void inClauseWithFunctionAndLiterals() {
|
||||
|
||||
assertQuery("""
|
||||
select f from FooEntity f where upper(f.name) IN ('Y', 'Basic', 'Remit')
|
||||
""");
|
||||
assertQuery(
|
||||
"""
|
||||
select count(f) from FooEntity f where f.status IN (com.example.eql_bug_check.entity.FooStatus.FOO, com.example.eql_bug_check.entity.FooStatus.BAR)
|
||||
""");
|
||||
}
|
||||
|
||||
@Test
|
||||
void notEqualsForTypeShouldWork() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user