File tree Expand file tree Collapse 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 Expand file tree Collapse file tree 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) {
101101 return false ;
102102 } else if (ctx instanceof HqlParser .InsertStatementContext ) {
103103 return false ;
104+ } else if (ctx instanceof HqlParser .DeleteStatementContext ) {
105+ return false ;
106+ } else if (ctx instanceof HqlParser .UpdateStatementContext ) {
107+ return false ;
104108 } else {
105- return isSubquery (ctx .getParent ());
109+ return ctx . getParent () != null ? isSubquery (ctx .getParent ()) : false ;
106110 }
107111 }
108112
Original file line number Diff line number Diff line change @@ -995,16 +995,23 @@ void fromWithoutAPrimaryAliasShouldWork() {
995995 .isEqualTo ("FROM Story WHERE enabled = true order by created desc" );
996996 }
997997
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 ) {
10081015 assertThat (createQueryFor (query , Sort .unsorted ())).isEqualToIgnoringWhitespace (query );
10091016 }
10101017
You can’t perform that action at this time.
0 commit comments