Skip to content

Commit 34a9c04

Browse files
committed
NEW should be legal as a token in a state field path expression in JPQL.
A multi-node token that has NEW as one of its elements should work just fine in a JPQL query. See #3128
1 parent bdbab71 commit 34a9c04

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4

+1
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,7 @@ identification_variable
602602
| INNER
603603
| KEY
604604
| LEFT
605+
| NEW
605606
| ORDER
606607
| OUTER
607608
| FLOOR

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/HqlQueryRendererTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -1584,4 +1584,20 @@ and CTM_UTLRAW_NLSSORT_LOWER(b.nome) like lower(:nome)
15841584
order by CTM_UTLRAW_NLSSORT_LOWER(b.nome) ASC
15851585
""");
15861586
}
1587+
1588+
@Test // GH-3128
1589+
void newShouldBeLegalAsPartOfAStateFieldPathExpression() {
1590+
1591+
assertQuery("""
1592+
SELECT j
1593+
FROM AgentUpdateTask j
1594+
WHERE j.creationTimestamp < :date
1595+
AND (j.status = com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.NEW
1596+
OR
1597+
j.status = com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.STARTED
1598+
OR
1599+
j.status = com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.QUEUED)
1600+
ORDER BY j.id
1601+
""");
1602+
}
15871603
}

spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTests.java

+16
Original file line numberDiff line numberDiff line change
@@ -967,4 +967,20 @@ void timeShouldBeAValidParameterName() {
967967
WHERE L.isLocked = FALSE OR L.forceUnlockTime < :time
968968
""");
969969
}
970+
971+
@Test // GH-3128
972+
void newShouldBeLegalAsPartOfAStateFieldPathExpression() {
973+
974+
assertQuery("""
975+
SELECT j
976+
FROM AgentUpdateTask j
977+
WHERE j.creationTimestamp < :date
978+
AND (j.status = com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.NEW
979+
OR
980+
j.status = com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.STARTED
981+
OR
982+
j.status = com.ca.apm.acc.configserver.core.domain.jobs.AgentUpdateTaskStatus.QUEUED)
983+
ORDER BY j.id
984+
""");
985+
}
970986
}

0 commit comments

Comments
 (0)