Skip to content

Commit 4447a53

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 edbfa86 commit 4447a53

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
@@ -1289,7 +1289,7 @@ public List<JpaQueryParsingToken> visitSignedNumericLiteral(HqlParser.SignedNume
12891289

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

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

12951295
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)