Skip to content

Commit

Permalink
Fix EQL grammar to accept literals in constructor expressions.
Browse files Browse the repository at this point in the history
Original Pull Request: #3695
  • Loading branch information
mp911de authored and christophstrobl committed Dec 20, 2024
1 parent 5c6cf9c commit b1cec72
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ constructor_item
| scalar_expression
| aggregate_expression
| identification_variable
| literal
;

aggregate_expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -695,19 +695,19 @@ public QueryTokenStream visitConstructor_expression(EqlParser.Constructor_expres
@Override
public QueryTokenStream visitConstructor_item(EqlParser.Constructor_itemContext ctx) {

QueryRendererBuilder builder = QueryRenderer.builder();

if (ctx.single_valued_path_expression() != null) {
builder.append(visit(ctx.single_valued_path_expression()));
return visit(ctx.single_valued_path_expression());
} else if (ctx.scalar_expression() != null) {
builder.append(visit(ctx.scalar_expression()));
return visit(ctx.scalar_expression());
} else if (ctx.aggregate_expression() != null) {
builder.append(visit(ctx.aggregate_expression()));
return visit(ctx.aggregate_expression());
} else if (ctx.identification_variable() != null) {
builder.append(visit(ctx.identification_variable()));
return visit(ctx.identification_variable());
} else if (ctx.literal() != null) {
return visit(ctx.literal());
}

return builder;
return QueryTokenStream.empty();
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ void numericLiterals() {
assertQuery("SELECT s FROM Stat s WHERE s.ratio > 3.14e32D");
}

@Test // GH-3308
void newWithStrings() {
assertQuery("select new com.example.demo.SampleObject(se.id, se.sampleValue, \"java\") from SampleEntity se");
}

@Test
void orderByClause() {

Expand Down

0 comments on commit b1cec72

Please sign in to comment.