Skip to content

Commit 8a2a605

Browse files
committed
Properly implement handling sort items.
See #2962 Original Pull Request: #2965
1 parent cc90152 commit 8a2a605

File tree

2 files changed

+3
-25
lines changed
  • spring-data-jpa/src/main

2 files changed

+3
-25
lines changed

spring-data-jpa/src/main/antlr4/org/springframework/data/jpa/repository/query/Hql.g4

+1-5
Original file line numberDiff line numberDiff line change
@@ -139,10 +139,6 @@ values
139139
: '(' expression (',' expression)* ')'
140140
;
141141

142-
projectedItem
143-
: (expression | instantiation) alias?
144-
;
145-
146142
instantiation
147143
: NEW instantiationTarget '(' instantiationArguments ')'
148144
;
@@ -254,7 +250,7 @@ groupByClause
254250
;
255251

256252
orderByClause
257-
: ORDER BY projectedItem (',' projectedItem)*
253+
: ORDER BY sortedItem (',' sortedItem)*
258254
;
259255

260256
havingClause

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

+2-20
Original file line numberDiff line numberDiff line change
@@ -457,24 +457,6 @@ public List<JpaQueryParsingToken> visitValues(HqlParser.ValuesContext ctx) {
457457
return tokens;
458458
}
459459

460-
@Override
461-
public List<JpaQueryParsingToken> visitProjectedItem(HqlParser.ProjectedItemContext ctx) {
462-
463-
List<JpaQueryParsingToken> tokens = new ArrayList<>();
464-
465-
if (ctx.expression() != null) {
466-
tokens.addAll(visit(ctx.expression()));
467-
} else if (ctx.instantiation() != null) {
468-
tokens.addAll(visit(ctx.instantiation()));
469-
}
470-
471-
if (ctx.alias() != null) {
472-
tokens.addAll(visit(ctx.alias()));
473-
}
474-
475-
return tokens;
476-
}
477-
478460
@Override
479461
public List<JpaQueryParsingToken> visitInstantiation(HqlParser.InstantiationContext ctx) {
480462

@@ -858,8 +840,8 @@ public List<JpaQueryParsingToken> visitOrderByClause(HqlParser.OrderByClauseCont
858840
tokens.add(new JpaQueryParsingToken(ctx.ORDER()));
859841
tokens.add(new JpaQueryParsingToken(ctx.BY()));
860842

861-
ctx.projectedItem().forEach(projectedItemContext -> {
862-
tokens.addAll(visit(projectedItemContext));
843+
ctx.sortedItem().forEach(sortedItemContext -> {
844+
tokens.addAll(visit(sortedItemContext));
863845
NOSPACE(tokens);
864846
tokens.add(TOKEN_COMMA);
865847
});

0 commit comments

Comments
 (0)