Skip to content

Commit

Permalink
Properly implement handling sort items.
Browse files Browse the repository at this point in the history
See #2962
  • Loading branch information
gregturn committed May 22, 2023
1 parent 13f6e51 commit b825903
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -139,10 +139,6 @@ values
: '(' expression (',' expression)* ')'
;

projectedItem
: (expression | instantiation) alias?
;

instantiation
: NEW instantiationTarget '(' instantiationArguments ')'
;
Expand Down Expand Up @@ -254,7 +250,7 @@ groupByClause
;

orderByClause
: ORDER BY projectedItem (',' projectedItem)*
: ORDER BY sortedItem (',' sortedItem)*
;

havingClause
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,24 +457,6 @@ public List<JpaQueryParsingToken> visitValues(HqlParser.ValuesContext ctx) {
return tokens;
}

@Override
public List<JpaQueryParsingToken> visitProjectedItem(HqlParser.ProjectedItemContext ctx) {

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

if (ctx.expression() != null) {
tokens.addAll(visit(ctx.expression()));
} else if (ctx.instantiation() != null) {
tokens.addAll(visit(ctx.instantiation()));
}

if (ctx.alias() != null) {
tokens.addAll(visit(ctx.alias()));
}

return tokens;
}

@Override
public List<JpaQueryParsingToken> visitInstantiation(HqlParser.InstantiationContext ctx) {

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

ctx.projectedItem().forEach(projectedItemContext -> {
tokens.addAll(visit(projectedItemContext));
ctx.sortedItem().forEach(sortedItemContext -> {
tokens.addAll(visit(sortedItemContext));
NOSPACE(tokens);
tokens.add(TOKEN_COMMA);
});
Expand Down

0 comments on commit b825903

Please sign in to comment.