Skip to content

Commit

Permalink
Fix regression in HQL parsing when primary alias is missing
Browse files Browse the repository at this point in the history
  • Loading branch information
christophstrobl committed Feb 28, 2025
1 parent 4b828a0 commit ced70b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,13 @@ public QueryRendererBuilder visitFromQuery(HqlParser.FromQueryContext ctx) {

if (ctx.fromClause() != null) {
builder.appendExpression(visit(ctx.fromClause()));
if(primaryFromAlias == null) {
builder.append(TOKEN_AS);
builder.append(TOKEN_DOUBLE_UNDERSCORE);
}
}


if (ctx.whereClause() != null) {
builder.appendExpression(visit(ctx.whereClause()));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -919,11 +919,11 @@ void queryParserPicksCorrectAliasAmidstMultipleAlises() {
assertThat(alias("select u from User as u left join u.roles as r")).isEqualTo("u");
}

@Test // GH-2032
@Test // GH-2032, GH-3792
void countQueryShouldWorkEvenWithoutExplicitAlias() {

assertCountQuery("FROM BookError WHERE portal = :portal",
"select count(__) FROM BookError WHERE portal = :portal");
"select count(__) FROM BookError AS __ WHERE portal = :portal");

assertCountQuery("FROM BookError b WHERE portal = :portal",
"select count(b) FROM BookError b WHERE portal = :portal");
Expand Down

0 comments on commit ced70b6

Please sign in to comment.