File tree Expand file tree Collapse file tree 5 files changed +55
-2
lines changed Expand file tree Collapse file tree 5 files changed +55
-2
lines changed Original file line number Diff line number Diff line change @@ -306,5 +306,14 @@ public async Task UnaryMinusBeforeParenthesesHandledCorrectlyAsync()
306
306
Assert . That ( actualWorkaround , Is . EqualTo ( - 2 ) ) ;
307
307
}
308
308
}
309
+
310
+ //NH-3249 (GH-1285)
311
+ [ Test ]
312
+ public async Task CountDistinctOnFunctionAsync ( )
313
+ {
314
+ var hql = @"SELECT COUNT(DISTINCT DATE(m.birthdate)) FROM Mammal m" ;
315
+ using ( var s = OpenSession ( ) )
316
+ await ( s . CreateQuery ( hql ) . ListAsync ( ) ) ;
317
+ }
309
318
}
310
319
}
Original file line number Diff line number Diff line change @@ -40,6 +40,21 @@ public async Task CountDistinctProperty_ReturnsNumberOfDistinctEntriesForThatPro
40
40
Assert . That ( result , Is . EqualTo ( 387 ) ) ;
41
41
}
42
42
43
+ //NH-3249 (GH-1285)
44
+ [ Test ]
45
+ public async Task CountDistinctFunc_ReturnsNumberOfDistinctEntriesForThatFuncAsync ( )
46
+ {
47
+ if ( ! TestDialect . SupportsCountDistinct )
48
+ Assert . Ignore ( "Dialect does not support count distinct" ) ;
49
+
50
+ var result = await ( db . Orders
51
+ . Select ( x => x . ShippingDate . Value . Date )
52
+ . Distinct ( )
53
+ . CountAsync ( ) ) ;
54
+
55
+ Assert . That ( result , Is . EqualTo ( 387 ) ) ;
56
+ }
57
+
43
58
[ Test ]
44
59
public async Task CountProperty_ReturnsNumberOfNonNullEntriesForThatPropertyAsync ( )
45
60
{
Original file line number Diff line number Diff line change @@ -337,5 +337,14 @@ public void UnaryMinusBeforeParenthesesHandledCorrectly()
337
337
Assert . That ( actualWorkaround , Is . EqualTo ( - 2 ) ) ;
338
338
}
339
339
}
340
+
341
+ //NH-3249 (GH-1285)
342
+ [ Test ]
343
+ public void CountDistinctOnFunction ( )
344
+ {
345
+ var hql = @"SELECT COUNT(DISTINCT DATE(m.birthdate)) FROM Mammal m" ;
346
+ using ( var s = OpenSession ( ) )
347
+ s . CreateQuery ( hql ) . List ( ) ;
348
+ }
340
349
}
341
350
}
Original file line number Diff line number Diff line change @@ -28,6 +28,21 @@ public void CountDistinctProperty_ReturnsNumberOfDistinctEntriesForThatProperty(
28
28
Assert . That ( result , Is . EqualTo ( 387 ) ) ;
29
29
}
30
30
31
+ //NH-3249 (GH-1285)
32
+ [ Test ]
33
+ public void CountDistinctFunc_ReturnsNumberOfDistinctEntriesForThatFunc ( )
34
+ {
35
+ if ( ! TestDialect . SupportsCountDistinct )
36
+ Assert . Ignore ( "Dialect does not support count distinct" ) ;
37
+
38
+ var result = db . Orders
39
+ . Select ( x => x . ShippingDate . Value . Date )
40
+ . Distinct ( )
41
+ . Count ( ) ;
42
+
43
+ Assert . That ( result , Is . EqualTo ( 387 ) ) ;
44
+ }
45
+
31
46
[ Test ]
32
47
public void CountProperty_ReturnsNumberOfNonNullEntriesForThatProperty ( )
33
48
{
Original file line number Diff line number Diff line change @@ -627,9 +627,14 @@ aggregateArgument
627
627
;
628
628
629
629
aggregateDistinctAll
630
- : ( ( DISTINCT | ALL )? ( path | collectionExpr ) )
630
+ : ( distinctAll aggregateArgument ) => (distinctAll aggregateArgument)
631
+ | aggregateArgument
631
632
;
632
-
633
+
634
+ distinctAll
635
+ : ( DISTINCT | ALL )
636
+ ;
637
+
633
638
//## collection: ( OPEN query CLOSE ) | ( ' elements' |' indices' OPEN path CLOSE );
634
639
635
640
collectionExpr
You can’t perform that action at this time.
0 commit comments