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
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) {
95
95
96
96
if (ctx .fromClause () != null ) {
97
97
builder .appendExpression (visit (ctx .fromClause ()));
98
+ if (primaryFromAlias == null ) {
99
+ builder .append (TOKEN_AS );
100
+ builder .append (TOKEN_DOUBLE_UNDERSCORE );
101
+ }
98
102
}
99
103
104
+
100
105
if (ctx .whereClause () != null ) {
101
106
builder .appendExpression (visit (ctx .whereClause ()));
102
107
}
Original file line number Diff line number Diff line change @@ -919,11 +919,11 @@ void queryParserPicksCorrectAliasAmidstMultipleAlises() {
919
919
assertThat (alias ("select u from User as u left join u.roles as r" )).isEqualTo ("u" );
920
920
}
921
921
922
- @ Test // GH-2032
922
+ @ Test // GH-2032, GH-3792
923
923
void countQueryShouldWorkEvenWithoutExplicitAlias () {
924
924
925
925
assertCountQuery ("FROM BookError WHERE portal = :portal" ,
926
- "select count(__) FROM BookError WHERE portal = :portal" );
926
+ "select count(__) FROM BookError AS __ WHERE portal = :portal" );
927
927
928
928
assertCountQuery ("FROM BookError b WHERE portal = :portal" ,
929
929
"select count(b) FROM BookError b WHERE portal = :portal" );
You can’t perform that action at this time.
0 commit comments