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()
306306 Assert . That ( actualWorkaround , Is . EqualTo ( - 2 ) ) ;
307307 }
308308 }
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+ }
309318 }
310319}
Original file line number Diff line number Diff line change @@ -40,6 +40,21 @@ public async Task CountDistinctProperty_ReturnsNumberOfDistinctEntriesForThatPro
4040 Assert . That ( result , Is . EqualTo ( 387 ) ) ;
4141 }
4242
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+
4358 [ Test ]
4459 public async Task CountProperty_ReturnsNumberOfNonNullEntriesForThatPropertyAsync ( )
4560 {
Original file line number Diff line number Diff line change @@ -337,5 +337,14 @@ public void UnaryMinusBeforeParenthesesHandledCorrectly()
337337 Assert . That ( actualWorkaround , Is . EqualTo ( - 2 ) ) ;
338338 }
339339 }
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+ }
340349 }
341350}
Original file line number Diff line number Diff line change @@ -28,6 +28,21 @@ public void CountDistinctProperty_ReturnsNumberOfDistinctEntriesForThatProperty(
2828 Assert . That ( result , Is . EqualTo ( 387 ) ) ;
2929 }
3030
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+
3146 [ Test ]
3247 public void CountProperty_ReturnsNumberOfNonNullEntriesForThatProperty ( )
3348 {
Original file line number Diff line number Diff line change @@ -627,9 +627,14 @@ aggregateArgument
627627 ;
628628
629629aggregateDistinctAll
630- : ( ( DISTINCT | ALL )? ( path | collectionExpr ) )
630+ : ( distinctAll aggregateArgument ) => (distinctAll aggregateArgument)
631+ | aggregateArgument
631632 ;
632-
633+
634+ distinctAll
635+ : ( DISTINCT | ALL )
636+ ;
637+
633638//## collection: ( OPEN query CLOSE ) | ( ' elements' |' indices' OPEN path CLOSE );
634639
635640collectionExpr
You can’t perform that action at this time.
0 commit comments