File tree Expand file tree Collapse file tree 6 files changed +57
-5
lines changed
antlr4/org/springframework/data/jpa/repository/query
java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query Expand file tree Collapse file tree 6 files changed +57
-5
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,12 @@ in_expression
354354
355355in_item
356356 : literal
357+ | string_expression
358+ | boolean_literal
359+ | numeric_literal
360+ | date_time_timestamp_literal
357361 | single_valued_input_parameter
362+ | conditional_expression
358363 ;
359364
360365like_expression
Original file line number Diff line number Diff line change @@ -342,7 +342,12 @@ in_expression
342342
343343in_item
344344 : literal
345+ | string_expression
346+ | boolean_literal
347+ | numeric_literal
348+ | date_time_timestamp_literal
345349 | single_valued_input_parameter
350+ | conditional_expression
346351 ;
347352
348353like_expression
Original file line number Diff line number Diff line change @@ -1189,15 +1189,23 @@ public QueryTokenStream visitIn_expression(EqlParser.In_expressionContext ctx) {
11891189 @ Override
11901190 public QueryTokenStream visitIn_item (EqlParser .In_itemContext ctx ) {
11911191
1192- QueryRendererBuilder builder = QueryRenderer .builder ();
1193-
11941192 if (ctx .literal () != null ) {
1195- builder .append (visit (ctx .literal ()));
1193+ return visit (ctx .literal ());
1194+ } else if (ctx .string_expression () != null ) {
1195+ return visit (ctx .string_expression ());
1196+ } else if (ctx .boolean_literal () != null ) {
1197+ return visit (ctx .boolean_literal ());
1198+ } else if (ctx .numeric_literal () != null ) {
1199+ return visit (ctx .numeric_literal ());
1200+ } else if (ctx .date_time_timestamp_literal () != null ) {
1201+ return visit (ctx .date_time_timestamp_literal ());
11961202 } else if (ctx .single_valued_input_parameter () != null ) {
1197- builder .append (visit (ctx .single_valued_input_parameter ()));
1203+ return visit (ctx .single_valued_input_parameter ());
1204+ } else if (ctx .conditional_expression () != null ) {
1205+ return visit (ctx .conditional_expression ());
11981206 }
11991207
1200- return builder ;
1208+ return QueryTokenStream . empty () ;
12011209 }
12021210
12031211 @ Override
Original file line number Diff line number Diff line change @@ -1113,8 +1113,18 @@ public QueryTokenStream visitIn_item(JpqlParser.In_itemContext ctx) {
11131113
11141114 if (ctx .literal () != null ) {
11151115 return visit (ctx .literal ());
1116+ } else if (ctx .string_expression () != null ) {
1117+ return visit (ctx .string_expression ());
1118+ } else if (ctx .boolean_literal () != null ) {
1119+ return visit (ctx .boolean_literal ());
1120+ } else if (ctx .numeric_literal () != null ) {
1121+ return visit (ctx .numeric_literal ());
1122+ } else if (ctx .date_time_timestamp_literal () != null ) {
1123+ return visit (ctx .date_time_timestamp_literal ());
11161124 } else if (ctx .single_valued_input_parameter () != null ) {
11171125 return visit (ctx .single_valued_input_parameter ());
1126+ } else if (ctx .conditional_expression () != null ) {
1127+ return visit (ctx .conditional_expression ());
11181128 }
11191129
11201130 return QueryTokenStream .empty ();
Original file line number Diff line number Diff line change @@ -555,6 +555,18 @@ WHERE TYPE(e) IN :empTypes
555555 """ );
556556 }
557557
558+ @ Test
559+ void inClauseWithFunctionAndLiterals () {
560+
561+ assertQuery ("""
562+ select f from FooEntity f where upper(f.name) IN ('Y', 'Basic', 'Remit')
563+ """ );
564+ assertQuery (
565+ """
566+ select count(f) from FooEntity f where f.status IN (com.example.eql_bug_check.entity.FooStatus.FOO, com.example.eql_bug_check.entity.FooStatus.BAR)
567+ """ );
568+ }
569+
558570 @ Test
559571 void notEqualsForTypeShouldWork () {
560572
Original file line number Diff line number Diff line change @@ -556,6 +556,18 @@ WHERE TYPE(e) IN :empTypes
556556 """ );
557557 }
558558
559+ @ Test
560+ void inClauseWithFunctionAndLiterals () {
561+
562+ assertQuery ("""
563+ select f from FooEntity f where upper(f.name) IN ('Y', 'Basic', 'Remit')
564+ """ );
565+ assertQuery (
566+ """
567+ select count(f) from FooEntity f where f.status IN (com.example.eql_bug_check.entity.FooStatus.FOO, com.example.eql_bug_check.entity.FooStatus.BAR)
568+ """ );
569+ }
570+
559571 @ Test
560572 void notEqualsForTypeShouldWork () {
561573
You can’t perform that action at this time.
0 commit comments