From 7eeca108f43f173bed359b75a51d647f6d3f2d3f Mon Sep 17 00:00:00 2001 From: "Greg L. Turnquist" Date: Wed, 2 Aug 2023 14:20:44 -0500 Subject: [PATCH] TIME should be valid parameter name for JPQL queries. See #3093 --- .../springframework/data/jpa/repository/query/Jpql.g4 | 1 + .../data/jpa/repository/query/JpqlQueryRenderer.java | 2 ++ .../jpa/repository/query/JpqlQueryRendererTests.java | 9 +++++++++ 3 files changed, 12 insertions(+) diff --git a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 index 4a23f4c14b..5c63a543b1 100644 --- a/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 +++ b/spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Jpql.g4 @@ -606,6 +606,7 @@ identification_variable | OUTER | FLOOR | SIGN + | TIME | TYPE | VALUE) ; diff --git a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java index b5a41fe998..7ff5a6f393 100644 --- a/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java +++ b/spring-data-jpa/src/main/java/org/springframework/data/jpa/repository/query/JpqlQueryRenderer.java @@ -544,9 +544,11 @@ public List visitUpdate_clause(JpqlParser.Update_clauseCon ctx.update_item().forEach(updateItemContext -> { tokens.addAll(visit(updateItemContext)); + NOSPACE(tokens); tokens.add(TOKEN_COMMA); }); CLIP(tokens); + SPACE(tokens); return tokens; } diff --git a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTests.java b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTests.java index bc0938c50c..c30dcbf71f 100644 --- a/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTests.java +++ b/spring-data-jpa/src/test/java/org/springframework/data/jpa/repository/query/JpqlQueryRendererTests.java @@ -958,4 +958,13 @@ void alternateNotEqualsOperatorShouldWork() { void dateAndFromShouldBeValidNames() { assertQuery("SELECT e FROM Entity e WHERE e.embeddedId.date BETWEEN :from AND :to"); } + + @Test // GH-3092 + void timeShouldBeAValidParameterName() { + assertQuery(""" + UPDATE Lock L + SET L.isLocked = TRUE, L.forceUnlockTime = :forceUnlockTime + WHERE L.isLocked = FALSE OR L.forceUnlockTime < :time + """); + } }