@@ -681,18 +681,22 @@ subtype
|
||||
|
||||
collection_valued_field
|
||||
: identification_variable
|
||||
| reserved_word
|
||||
;
|
||||
|
||||
single_valued_object_field
|
||||
: identification_variable
|
||||
| reserved_word
|
||||
;
|
||||
|
||||
state_field
|
||||
: identification_variable
|
||||
| reserved_word
|
||||
;
|
||||
|
||||
collection_value_field
|
||||
: identification_variable
|
||||
| reserved_word
|
||||
;
|
||||
|
||||
entity_name
|
||||
|
||||
@@ -2164,7 +2164,7 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
tokens.add(new JpaQueryParsingToken(ctx.INTLITERAL()));
|
||||
} else if (ctx.FLOATLITERAL() != null) {
|
||||
tokens.add(new JpaQueryParsingToken(ctx.FLOATLITERAL()));
|
||||
} else if(ctx.LONGLITERAL() != null) {
|
||||
} else if (ctx.LONGLITERAL() != null) {
|
||||
tokens.add(new JpaQueryParsingToken(ctx.LONGLITERAL()));
|
||||
} else if (ctx.boolean_literal() != null) {
|
||||
tokens.addAll(visit(ctx.boolean_literal()));
|
||||
@@ -2226,7 +2226,7 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
return List.of(new JpaQueryParsingToken(ctx.INTLITERAL()));
|
||||
} else if (ctx.FLOATLITERAL() != null) {
|
||||
return List.of(new JpaQueryParsingToken(ctx.FLOATLITERAL()));
|
||||
} else if(ctx.LONGLITERAL() != null) {
|
||||
} else if (ctx.LONGLITERAL() != null) {
|
||||
return List.of(new JpaQueryParsingToken(ctx.LONGLITERAL()));
|
||||
} else {
|
||||
return List.of();
|
||||
@@ -2275,21 +2275,36 @@ class JpqlQueryRenderer extends JpqlBaseVisitor<List<JpaQueryParsingToken>> {
|
||||
|
||||
@Override
|
||||
public List<JpaQueryParsingToken> visitCollection_valued_field(JpqlParser.Collection_valued_fieldContext ctx) {
|
||||
if (ctx.reserved_word() != null) {
|
||||
return visit(ctx.reserved_word());
|
||||
}
|
||||
return visit(ctx.identification_variable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JpaQueryParsingToken> visitSingle_valued_object_field(JpqlParser.Single_valued_object_fieldContext ctx) {
|
||||
|
||||
if (ctx.reserved_word() != null) {
|
||||
return visit(ctx.reserved_word());
|
||||
}
|
||||
return visit(ctx.identification_variable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JpaQueryParsingToken> visitState_field(JpqlParser.State_fieldContext ctx) {
|
||||
|
||||
if (ctx.reserved_word() != null) {
|
||||
return visit(ctx.reserved_word());
|
||||
}
|
||||
return visit(ctx.identification_variable());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<JpaQueryParsingToken> visitCollection_value_field(JpqlParser.Collection_value_fieldContext ctx) {
|
||||
|
||||
if (ctx.reserved_word() != null) {
|
||||
return visit(ctx.reserved_word());
|
||||
}
|
||||
return visit(ctx.identification_variable());
|
||||
}
|
||||
|
||||
|
||||
@@ -1031,4 +1031,13 @@ class EqlQueryRendererTests {
|
||||
assertQuery("select e from Employee e where e.lateral = :_lateral");
|
||||
assertQuery("select te from TestEntity te where te.lateral = :lateral");
|
||||
}
|
||||
|
||||
@Test
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1674,4 +1674,13 @@ class HqlQueryRendererTests {
|
||||
String source = "select new com.company.%s.thing.stuff.ClassName(e.id) from Experience e".formatted(reservedWord);
|
||||
assertQuery(source);
|
||||
}
|
||||
|
||||
@Test
|
||||
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");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1033,4 +1033,13 @@ class JpqlQueryRendererTests {
|
||||
assertQuery(source);
|
||||
}
|
||||
|
||||
@Test
|
||||
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");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user