Skip to content

Commit 7eeca10

Browse files
committed
TIME should be valid parameter name for JPQL queries.
See #3093
1 parent 10c26d2 commit 7eeca10

File tree

3 files changed

+12
-0
lines changed

3 files changed

+12
-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
@@ -606,6 +606,7 @@ identification_variable
606606
| OUTER
607607
| FLOOR
608608
| SIGN
609+
| TIME
609610
| TYPE
610611
| VALUE)
611612
;

spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java

+2
Original file line numberDiff line numberDiff line change
@@ -544,9 +544,11 @@ public List<JpaQueryParsingToken> visitUpdate_clause(JpqlParser.Update_clauseCon
544544

545545
ctx.update_item().forEach(updateItemContext -> {
546546
tokens.addAll(visit(updateItemContext));
547+
NOSPACE(tokens);
547548
tokens.add(TOKEN_COMMA);
548549
});
549550
CLIP(tokens);
551+
SPACE(tokens);
550552

551553
return tokens;
552554
}

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

+9
Original file line numberDiff line numberDiff line change
@@ -958,4 +958,13 @@ void alternateNotEqualsOperatorShouldWork() {
958958
void dateAndFromShouldBeValidNames() {
959959
assertQuery("SELECT e FROM Entity e WHERE e.embeddedId.date BETWEEN :from AND :to");
960960
}
961+
962+
@Test // GH-3092
963+
void timeShouldBeAValidParameterName() {
964+
assertQuery("""
965+
UPDATE Lock L
966+
SET L.isLocked = TRUE, L.forceUnlockTime = :forceUnlockTime
967+
WHERE L.isLocked = FALSE OR L.forceUnlockTime < :time
968+
""");
969+
}
961970
}

0 commit comments

Comments
 (0)