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) {
48
48
return false ;
49
49
} else if (ctx instanceof HqlParser .InsertStatementContext ) {
50
50
return false ;
51
+ } else if (ctx instanceof HqlParser .DeleteStatementContext ) {
52
+ return false ;
53
+ } else if (ctx instanceof HqlParser .UpdateStatementContext ) {
54
+ return false ;
51
55
} else {
52
- return isSubquery (ctx .getParent ());
56
+ return ctx . getParent () != null && isSubquery (ctx .getParent ());
53
57
}
54
58
}
55
59
Original file line number Diff line number Diff line change @@ -1027,16 +1027,22 @@ void fromWithoutAPrimaryAliasShouldWork() {
1027
1027
.isEqualTo ("FROM Story WHERE enabled = true order by created desc" );
1028
1028
}
1029
1029
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 ) {
1040
1046
assertThat (createQueryFor (query , Sort .unsorted ())).isEqualToIgnoringWhitespace (query );
1041
1047
}
1042
1048
@@ -1133,7 +1139,6 @@ void sortShouldBeAppendedToSubSelectWithSetOperatorInSubselect(String alias) {
1133
1139
}
1134
1140
assertThat (count ).describedAs ("Found order by clause more than once in: \n %s" , it ).isOne ();
1135
1141
});
1136
-
1137
1142
}
1138
1143
1139
1144
private void assertCountQuery (String originalQuery , String countQuery ) {
You can’t perform that action at this time.
0 commit comments