File tree 2 files changed +22
-11
lines changed
main/java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query
2 files changed +22
-11
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,12 @@ private static boolean isSubquery(ParserRuleContext ctx) {
101
101
return false ;
102
102
} else if (ctx instanceof HqlParser .InsertStatementContext ) {
103
103
return false ;
104
+ } else if (ctx instanceof HqlParser .DeleteStatementContext ) {
105
+ return false ;
106
+ } else if (ctx instanceof HqlParser .UpdateStatementContext ) {
107
+ return false ;
104
108
} else {
105
- return isSubquery (ctx .getParent ());
109
+ return ctx . getParent () != null ? isSubquery (ctx .getParent ()) : false ;
106
110
}
107
111
}
108
112
Original file line number Diff line number Diff line change @@ -995,16 +995,23 @@ void fromWithoutAPrimaryAliasShouldWork() {
995
995
.isEqualTo ("FROM Story WHERE enabled = true order by created desc" );
996
996
}
997
997
998
- @ Test // GH-2977
999
- void isSubqueryThrowsException () {
1000
-
1001
- String query = """
1002
- insert into MyEntity (id, col)
1003
- select max(id), col
1004
- from MyEntityStaging
1005
- group by col
1006
- """ ;
1007
-
998
+ @ ParameterizedTest
999
+ @ ValueSource (strings = { """
1000
+ insert into MyEntity (id, col)
1001
+ select max(id), col
1002
+ from MyEntityStaging
1003
+ group by col
1004
+ """ , """
1005
+ update MyEntity AS mes
1006
+ set mes.col = 'test'
1007
+ where mes.id = 1
1008
+ """ , """
1009
+ delete MyEntity AS mes
1010
+ where mes.col = 'test'
1011
+ """
1012
+
1013
+ }) // GH-2977, GH-3649
1014
+ void isSubqueryThrowsException (String query ) {
1008
1015
assertThat (createQueryFor (query , Sort .unsorted ())).isEqualToIgnoringWhitespace (query );
1009
1016
}
1010
1017
You can’t perform that action at this time.
0 commit comments