File tree Expand file tree Collapse file tree 2 files changed +29
-4
lines changed
main/java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query Expand file tree Collapse file tree 2 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -195,22 +195,22 @@ public QueryTokenStream visitCycleClause(HqlParser.CycleClauseContext ctx) {
195195 QueryRendererBuilder builder = QueryRenderer .builder ();
196196
197197 builder .append (QueryTokens .expression (ctx .CYCLE ().getText ()));
198- builder .append (visit (ctx .cteAttributes ()));
198+ builder .appendExpression (visit (ctx .cteAttributes ()));
199199 builder .append (QueryTokens .expression (ctx .SET ().getText ()));
200- builder .append (visit (ctx .identifier (0 )));
200+ builder .appendExpression (visit (ctx .identifier (0 )));
201201
202202 if (ctx .TO () != null ) {
203203
204204 builder .append (QueryTokens .expression (ctx .TO ().getText ()));
205205 builder .append (visit (ctx .literal (0 )));
206206 builder .append (QueryTokens .expression (ctx .DEFAULT ().getText ()));
207- builder .append (visit (ctx .literal (1 )));
207+ builder .appendExpression (visit (ctx .literal (1 )));
208208 }
209209
210210 if (ctx .USING () != null ) {
211211
212212 builder .append (QueryTokens .expression (ctx .USING ().getText ()));
213- builder .append (visit (ctx .identifier (1 )));
213+ builder .appendExpression (visit (ctx .identifier (1 )));
214214 }
215215
216216 return builder ;
Original file line number Diff line number Diff line change @@ -1730,6 +1730,31 @@ WITH maxId AS (select max(sr.snapshot.id) snapshotId from SnapshotReference sr
17301730 """ );
17311731 }
17321732
1733+ @ Test // GH-4012
1734+ void cteWithSearch () {
1735+
1736+ assertQuery ("""
1737+ WITH Tree AS (SELECT o.uuid AS test_uuid FROM DemoEntity o)
1738+ SEARCH BREADTH FIRST BY foo ASC NULLS FIRST, bar DESC NULLS LAST SET baz
1739+ SELECT test_uuid FROM Tree
1740+ """ );
1741+ }
1742+
1743+ @ Test // GH-4012
1744+ void cteWithCycle () {
1745+
1746+ assertQuery ("""
1747+ WITH Tree AS (SELECT o.uuid AS test_uuid FROM DemoEntity o) CYCLE test_uuid SET circular TO true DEFAULT false
1748+ SELECT test_uuid FROM Tree
1749+ """ );
1750+
1751+ assertQuery (
1752+ """
1753+ WITH Tree AS (SELECT o.uuid AS test_uuid FROM DemoEntity o) CYCLE test_uuid SET circular TO true DEFAULT false USING bar
1754+ SELECT test_uuid FROM Tree
1755+ """ );
1756+ }
1757+
17331758 @ Test // GH-2982
17341759 void floorShouldBeValidEntityName () {
17351760
You can’t perform that action at this time.
0 commit comments