File tree Expand file tree Collapse file tree 2 files changed +21
-12
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 +21
-12
lines changed Original file line number Diff line number Diff line change @@ -48,8 +48,12 @@ static boolean isSubquery(ParserRuleContext ctx) {
4848 return false ;
4949 } else if (ctx instanceof HqlParser .InsertStatementContext ) {
5050 return false ;
51+ } else if (ctx instanceof HqlParser .DeleteStatementContext ) {
52+ return false ;
53+ } else if (ctx instanceof HqlParser .UpdateStatementContext ) {
54+ return false ;
5155 } else {
52- return isSubquery (ctx .getParent ());
56+ return ctx . getParent () != null && isSubquery (ctx .getParent ());
5357 }
5458 }
5559
Original file line number Diff line number Diff line change @@ -1027,16 +1027,22 @@ void fromWithoutAPrimaryAliasShouldWork() {
10271027 .isEqualTo ("FROM Story WHERE enabled = true order by created desc" );
10281028 }
10291029
1030- @ Test // GH-2977
1031- void isSubqueryThrowsException () {
1032-
1033- String query = """
1034- insert into MyEntity (id, col)
1035- select max(id), col
1036- from MyEntityStaging
1037- group by col
1038- """ ;
1039-
1030+ @ ParameterizedTest
1031+ @ ValueSource (strings = { """
1032+ insert into MyEntity (id, col)
1033+ select max(id), col
1034+ from MyEntityStaging
1035+ group by col
1036+ """ , """
1037+ update MyEntity AS mes
1038+ set mes.col = 'test'
1039+ where mes.id = 1
1040+ """ , """
1041+ delete MyEntity AS mes
1042+ where mes.col = 'test'
1043+ """
1044+ }) // GH-2977, GH-3649
1045+ void isSubqueryThrowsException (String query ) {
10401046 assertThat (createQueryFor (query , Sort .unsorted ())).isEqualToIgnoringWhitespace (query );
10411047 }
10421048
@@ -1133,7 +1139,6 @@ void sortShouldBeAppendedToSubSelectWithSetOperatorInSubselect(String alias) {
11331139 }
11341140 assertThat (count ).describedAs ("Found order by clause more than once in: \n %s" , it ).isOne ();
11351141 });
1136-
11371142 }
11381143
11391144 private void assertCountQuery (String originalQuery , String countQuery ) {
You can’t perform that action at this time.
0 commit comments