Skip to content

Commit 786024b

Browse files
hgwrchristophstrobl
authored andcommitted
Fix hql rendering for signed numeric literals.
This commit fixes an issue where an extra space is added between the sign and the actual value of signed numerics. Closes: #3342 Original Pull Request: #3343
1 parent 4cdc421 commit 786024b

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1288,7 +1288,7 @@ public List<JpaQueryParsingToken> visitSignedNumericLiteral(HqlParser.SignedNume
12881288

12891289
List<JpaQueryParsingToken> tokens = new ArrayList<>();
12901290

1291-
tokens.add(new JpaQueryParsingToken(ctx.op));
1291+
tokens.add(new JpaQueryParsingToken(ctx.op, false));
12921292
tokens.addAll(visit(ctx.numericLiteral()));
12931293

12941294
return tokens;

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1635,4 +1635,9 @@ select extract(epoch from departureTime) AS epoch
16351635
group by extract(epoch from departureTime)
16361636
""");
16371637
}
1638+
1639+
@Test
1640+
void queryWithSignedNumericLiteralShouldWork() {
1641+
assertQuery("select -1");
1642+
}
16381643
}

0 commit comments

Comments
 (0)