File tree Expand file tree Collapse file tree 2 files changed +7
-2
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 +7
-2
lines changed Original file line number Diff line number Diff line change @@ -95,8 +95,13 @@ public QueryRendererBuilder visitFromQuery(HqlParser.FromQueryContext ctx) {
9595
9696 if (ctx .fromClause () != null ) {
9797 builder .appendExpression (visit (ctx .fromClause ()));
98+ if (primaryFromAlias == null ) {
99+ builder .append (TOKEN_AS );
100+ builder .append (TOKEN_DOUBLE_UNDERSCORE );
101+ }
98102 }
99103
104+
100105 if (ctx .whereClause () != null ) {
101106 builder .appendExpression (visit (ctx .whereClause ()));
102107 }
Original file line number Diff line number Diff line change @@ -919,11 +919,11 @@ void queryParserPicksCorrectAliasAmidstMultipleAlises() {
919919 assertThat (alias ("select u from User as u left join u.roles as r" )).isEqualTo ("u" );
920920 }
921921
922- @ Test // GH-2032
922+ @ Test // GH-2032, GH-3792
923923 void countQueryShouldWorkEvenWithoutExplicitAlias () {
924924
925925 assertCountQuery ("FROM BookError WHERE portal = :portal" ,
926- "select count(__) FROM BookError WHERE portal = :portal" );
926+ "select count(__) FROM BookError AS __ WHERE portal = :portal" );
927927
928928 assertCountQuery ("FROM BookError b WHERE portal = :portal" ,
929929 "select count(b) FROM BookError b WHERE portal = :portal" );
You can’t perform that action at this time.
0 commit comments