File tree 6 files changed +60
-9
lines changed
antlr4/org/springframework/data/jpa/repository/query
java/org/springframework/data/jpa/repository/query
test/java/org/springframework/data/jpa/repository/query
6 files changed +60
-9
lines changed Original file line number Diff line number Diff line change @@ -354,7 +354,12 @@ in_expression
354
354
355
355
in_item
356
356
: literal
357
+ | string_expression
358
+ | boolean_literal
359
+ | numeric_literal
360
+ | date_time_timestamp_literal
357
361
| single_valued_input_parameter
362
+ | conditional_expression
358
363
;
359
364
360
365
like_expression
Original file line number Diff line number Diff line change @@ -338,7 +338,12 @@ in_expression
338
338
339
339
in_item
340
340
: literal
341
+ | string_expression
342
+ | boolean_literal
343
+ | numeric_literal
344
+ | date_time_timestamp_literal
341
345
| single_valued_input_parameter
346
+ | conditional_expression
342
347
;
343
348
344
349
like_expression
Original file line number Diff line number Diff line change @@ -1270,15 +1270,23 @@ public List<JpaQueryParsingToken> visitIn_expression(EqlParser.In_expressionCont
1270
1270
@ Override
1271
1271
public List <JpaQueryParsingToken > visitIn_item (EqlParser .In_itemContext ctx ) {
1272
1272
1273
- List <JpaQueryParsingToken > tokens = new ArrayList <>();
1274
-
1275
1273
if (ctx .literal () != null ) {
1276
- tokens .addAll (visit (ctx .literal ()));
1274
+ return visit (ctx .literal ());
1275
+ } else if (ctx .string_expression () != null ) {
1276
+ return visit (ctx .string_expression ());
1277
+ } else if (ctx .boolean_literal () != null ) {
1278
+ return visit (ctx .boolean_literal ());
1279
+ } else if (ctx .numeric_literal () != null ) {
1280
+ return visit (ctx .numeric_literal ());
1281
+ } else if (ctx .date_time_timestamp_literal () != null ) {
1282
+ return visit (ctx .date_time_timestamp_literal ());
1277
1283
} else if (ctx .single_valued_input_parameter () != null ) {
1278
- tokens .addAll (visit (ctx .single_valued_input_parameter ()));
1284
+ return visit (ctx .single_valued_input_parameter ());
1285
+ } else if (ctx .conditional_expression () != null ) {
1286
+ return visit (ctx .conditional_expression ());
1279
1287
}
1280
1288
1281
- return tokens ;
1289
+ return new ArrayList <>() ;
1282
1290
}
1283
1291
1284
1292
@ Override
Original file line number Diff line number Diff line change @@ -1191,15 +1191,24 @@ public List<JpaQueryParsingToken> visitIn_expression(JpqlParser.In_expressionCon
1191
1191
@ Override
1192
1192
public List <JpaQueryParsingToken > visitIn_item (JpqlParser .In_itemContext ctx ) {
1193
1193
1194
- List <JpaQueryParsingToken > tokens = new ArrayList <>();
1195
1194
1196
1195
if (ctx .literal () != null ) {
1197
- tokens .addAll (visit (ctx .literal ()));
1196
+ return visit (ctx .literal ());
1197
+ } else if (ctx .string_expression () != null ) {
1198
+ return visit (ctx .string_expression ());
1199
+ } else if (ctx .boolean_literal () != null ) {
1200
+ return visit (ctx .boolean_literal ());
1201
+ } else if (ctx .numeric_literal () != null ) {
1202
+ return visit (ctx .numeric_literal ());
1203
+ } else if (ctx .date_time_timestamp_literal () != null ) {
1204
+ return visit (ctx .date_time_timestamp_literal ());
1198
1205
} else if (ctx .single_valued_input_parameter () != null ) {
1199
- tokens .addAll (visit (ctx .single_valued_input_parameter ()));
1206
+ return visit (ctx .single_valued_input_parameter ());
1207
+ } else if (ctx .conditional_expression () != null ) {
1208
+ return visit (ctx .conditional_expression ());
1200
1209
}
1201
1210
1202
- return tokens ;
1211
+ return new ArrayList <>() ;
1203
1212
}
1204
1213
1205
1214
@ Override
Original file line number Diff line number Diff line change @@ -561,6 +561,18 @@ WHERE TYPE(e) IN :empTypes
561
561
""" );
562
562
}
563
563
564
+ @ Test
565
+ void inClauseWithFunctionAndLiterals () {
566
+
567
+ assertQuery ("""
568
+ select f from FooEntity f where upper(f.name) IN ('Y', 'Basic', 'Remit')
569
+ """ );
570
+ assertQuery (
571
+ """
572
+ 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)
573
+ """ );
574
+ }
575
+
564
576
@ Test
565
577
void notEqualsForTypeShouldWork () {
566
578
Original file line number Diff line number Diff line change @@ -562,6 +562,18 @@ WHERE TYPE(e) IN :empTypes
562
562
""" );
563
563
}
564
564
565
+ @ Test
566
+ void inClauseWithFunctionAndLiterals () {
567
+
568
+ assertQuery ("""
569
+ select f from FooEntity f where upper(f.name) IN ('Y', 'Basic', 'Remit')
570
+ """ );
571
+ assertQuery (
572
+ """
573
+ 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)
574
+ """ );
575
+ }
576
+
565
577
@ Test
566
578
void notEqualsForTypeShouldWork () {
567
579
You can’t perform that action at this time.
0 commit comments