|
18 | 18 | import static org.assertj.core.api.Assertions.*; |
19 | 19 | import static org.springframework.data.jpa.repository.query.JpaQueryParsingToken.*; |
20 | 20 |
|
| 21 | +import java.util.stream.Stream; |
| 22 | + |
21 | 23 | import org.antlr.v4.runtime.CharStreams; |
22 | 24 | import org.antlr.v4.runtime.CommonTokenStream; |
23 | 25 | import org.junit.jupiter.api.Disabled; |
24 | 26 | import org.junit.jupiter.api.Test; |
25 | 27 | import org.junit.jupiter.params.ParameterizedTest; |
| 28 | +import org.junit.jupiter.params.provider.Arguments; |
| 29 | +import org.junit.jupiter.params.provider.MethodSource; |
26 | 30 | import org.junit.jupiter.params.provider.ValueSource; |
27 | 31 |
|
28 | 32 | /** |
@@ -57,6 +61,10 @@ private static String parseWithoutChanges(String query) { |
57 | 61 | return render(new HqlQueryRenderer().visit(parsedQuery)); |
58 | 62 | } |
59 | 63 |
|
| 64 | + public static Stream<Arguments> reservedWords() { |
| 65 | + return Stream.of("abs", "exp", "any", "case", "else", "index", "time").map(Arguments::of); |
| 66 | + } |
| 67 | + |
60 | 68 | private void assertQuery(String query) { |
61 | 69 |
|
62 | 70 | String slimmedDownQuery = reduceWhitespace(query); |
@@ -1661,4 +1669,12 @@ void signedLiteralShouldWork(String query) { |
1661 | 1669 | void signedExpressionsShouldWork(String query) { |
1662 | 1670 | assertQuery(query); |
1663 | 1671 | } |
| 1672 | + |
| 1673 | + @ParameterizedTest // GH-3451 |
| 1674 | + @MethodSource({"reservedWords"}) |
| 1675 | + void entityNameWithPackageContainingReservedWord(String reservedWord) { |
| 1676 | + |
| 1677 | + String source = "select new com.company.%s.thing.stuff.ClassName(e.id) from Experience e".formatted(reservedWord); |
| 1678 | + assertQuery(source); |
| 1679 | + } |
1664 | 1680 | } |
0 commit comments