File tree Expand file tree Collapse file tree 7 files changed +33
-28
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 7 files changed +33
-28
lines changed Original file line number Diff line number Diff line change @@ -219,8 +219,8 @@ constructor_item
219
219
;
220
220
221
221
aggregate_expression
222
- : (AVG | MAX | MIN | SUM ) ' (' (DISTINCT )? state_valued_path_expression ' )'
223
- | COUNT ' (' (DISTINCT )? (identification_variable | state_valued_path_expression | single_valued_object_path_expression) ' )'
222
+ : (AVG | MAX | MIN | SUM ) ' (' (DISTINCT )? simple_select_expression ' )'
223
+ | COUNT ' (' (DISTINCT )? simple_select_expression ' )'
224
224
| function_invocation
225
225
;
226
226
@@ -593,10 +593,7 @@ datetime_part
593
593
;
594
594
595
595
function_arg
596
- : literal
597
- | state_valued_path_expression
598
- | input_parameter
599
- | scalar_expression
596
+ : simple_select_expression
600
597
;
601
598
602
599
case_expression
Original file line number Diff line number Diff line change @@ -220,8 +220,8 @@ constructor_item
220
220
;
221
221
222
222
aggregate_expression
223
- : (AVG | MAX | MIN | SUM ) ' (' (DISTINCT )? state_valued_path_expression ' )'
224
- | COUNT ' (' (DISTINCT )? (identification_variable | state_valued_path_expression | single_valued_object_path_expression) ' )'
223
+ : (AVG | MAX | MIN | SUM ) ' (' (DISTINCT )? simple_select_expression ' )'
224
+ | COUNT ' (' (DISTINCT )? simple_select_expression ' )'
225
225
| function_invocation
226
226
;
227
227
@@ -593,10 +593,7 @@ datetime_part
593
593
;
594
594
595
595
function_arg
596
- : literal
597
- | state_valued_path_expression
598
- | input_parameter
599
- | scalar_expression
596
+ : simple_select_expression
600
597
;
601
598
602
599
case_expression
Original file line number Diff line number Diff line change @@ -494,7 +494,7 @@ public QueryTokenStream visitAggregate_expression(EqlParser.Aggregate_expression
494
494
builder .append (QueryTokens .expression (ctx .DISTINCT ()));
495
495
}
496
496
497
- builder .appendInline (visit (ctx .state_valued_path_expression ()));
497
+ builder .appendInline (visit (ctx .simple_select_expression ()));
498
498
builder .append (TOKEN_CLOSE_PAREN );
499
499
} else if (ctx .COUNT () != null ) {
500
500
@@ -503,13 +503,7 @@ public QueryTokenStream visitAggregate_expression(EqlParser.Aggregate_expression
503
503
if (ctx .DISTINCT () != null ) {
504
504
builder .append (QueryTokens .expression (ctx .DISTINCT ()));
505
505
}
506
- if (ctx .identification_variable () != null ) {
507
- builder .appendInline (visit (ctx .identification_variable ()));
508
- } else if (ctx .state_valued_path_expression () != null ) {
509
- builder .appendInline (visit (ctx .state_valued_path_expression ()));
510
- } else if (ctx .single_valued_object_path_expression () != null ) {
511
- builder .appendInline (visit (ctx .single_valued_object_path_expression ()));
512
- }
506
+ builder .appendInline (visit (ctx .simple_select_expression ()));
513
507
builder .append (TOKEN_CLOSE_PAREN );
514
508
} else if (ctx .function_invocation () != null ) {
515
509
builder .append (visit (ctx .function_invocation ()));
Original file line number Diff line number Diff line change @@ -495,7 +495,7 @@ public QueryTokenStream visitAggregate_expression(JpqlParser.Aggregate_expressio
495
495
builder .append (QueryTokens .expression (ctx .DISTINCT ()));
496
496
}
497
497
498
- builder .appendInline (visit (ctx .state_valued_path_expression ()));
498
+ builder .appendInline (visit (ctx .simple_select_expression ()));
499
499
builder .append (TOKEN_CLOSE_PAREN );
500
500
} else if (ctx .COUNT () != null ) {
501
501
@@ -504,13 +504,8 @@ public QueryTokenStream visitAggregate_expression(JpqlParser.Aggregate_expressio
504
504
if (ctx .DISTINCT () != null ) {
505
505
builder .append (QueryTokens .expression (ctx .DISTINCT ()));
506
506
}
507
- if (ctx .identification_variable () != null ) {
508
- builder .appendInline (visit (ctx .identification_variable ()));
509
- } else if (ctx .state_valued_path_expression () != null ) {
510
- builder .appendInline (visit (ctx .state_valued_path_expression ()));
511
- } else if (ctx .single_valued_object_path_expression () != null ) {
512
- builder .appendInline (visit (ctx .single_valued_object_path_expression ()));
513
- }
507
+
508
+ builder .appendInline (visit (ctx .simple_select_expression ()));
514
509
builder .append (TOKEN_CLOSE_PAREN );
515
510
} else if (ctx .function_invocation () != null ) {
516
511
builder .append (visit (ctx .function_invocation ()));
Original file line number Diff line number Diff line change @@ -1254,6 +1254,14 @@ void findOrdersThatHaveProductNamedByAParameter() {
1254
1254
""" );
1255
1255
}
1256
1256
1257
+ @ Test // GH-4013
1258
+ void minMaxFunctionsShouldWork () {
1259
+ assertQuery ("SELECT MAX(e.age), e.address.city FROM Employee e" );
1260
+ assertQuery ("SELECT MAX(1), e.address.city FROM Employee e" );
1261
+ assertQuery ("SELECT MAX(MIN(MOD(e.salary, 10))), e.address.city FROM Employee e" );
1262
+ assertQuery ("SELECT MIN(MOD(e.salary, 10)), e.address.city FROM Employee e" );
1263
+ }
1264
+
1257
1265
@ Test // GH-2982
1258
1266
void floorShouldBeValidEntityName () {
1259
1267
Original file line number Diff line number Diff line change @@ -2080,6 +2080,12 @@ void lnFunctionShouldWork() {
2080
2080
assertQuery ("select ln(7.5) from Element a" );
2081
2081
}
2082
2082
2083
+ @ Test // GH-4013
2084
+ void minMaxFunctionsShouldWork () {
2085
+ assertQuery ("SELECT MAX(MIN(MOD(e.salary, 10))), e.address.city FROM Employee e" );
2086
+ assertQuery ("SELECT MIN(MOD(e.salary, 10)), e.address.city FROM Employee e" );
2087
+ }
2088
+
2083
2089
@ Test // GH-2981
2084
2090
void cteWithClauseShouldWork () {
2085
2091
Original file line number Diff line number Diff line change @@ -1260,6 +1260,14 @@ void findOrdersThatHaveProductNamedByAParameter() {
1260
1260
""" );
1261
1261
}
1262
1262
1263
+ @ Test // GH-4013
1264
+ void minMaxFunctionsShouldWork () {
1265
+ assertQuery ("SELECT MAX(e.age), e.address.city FROM Employee e" );
1266
+ assertQuery ("SELECT MAX(1), e.address.city FROM Employee e" );
1267
+ assertQuery ("SELECT MAX(MIN(MOD(e.salary, 10))), e.address.city FROM Employee e" );
1268
+ assertQuery ("SELECT MIN(MOD(e.salary, 10)), e.address.city FROM Employee e" );
1269
+ }
1270
+
1263
1271
@ Test // GH-2982
1264
1272
void floorShouldBeValidEntityName () {
1265
1273
You can’t perform that action at this time.
0 commit comments