@@ -2570,6 +2570,7 @@ public override async Task GroupBy_Select_Distinct_Any_with_nullable_element(boo
25702570 """
25712571SELECT [o].[CustomerID] AS [Key], COUNT(DISTINCT ([o].[EmployeeID])) + COUNT(DISTINCT (CASE
25722572 WHEN [o].[EmployeeID] IS NULL THEN 1
2573+ ELSE CAST(NULL AS int)
25732574END)) AS [Employees], CASE
25742575 WHEN EXISTS (
25752576 SELECT 1
@@ -2839,6 +2840,7 @@ public override async Task GroupBy_aggregate_through_navigation_with_distinct_co
28392840 WHEN [c].[City] = N'London' THEN 1
28402841END) AS [Londons], COUNT(DISTINCT ([o].[CustomerID])) + COUNT(DISTINCT (CASE
28412842 WHEN [o].[CustomerID] IS NULL THEN 1
2843+ ELSE CAST(NULL AS int)
28422844END)) AS [Customers]
28432845FROM [Orders] AS [o]
28442846LEFT JOIN [Customers] AS [c] ON [o].[CustomerID] = [c].[CustomerID]
@@ -3469,8 +3471,10 @@ public override async Task GroupBy_Select_Distinct_aggregate(bool async)
34693471 """
34703472SELECT [o].[CustomerID] AS [Key], AVG(DISTINCT (CAST([o].[OrderID] AS float))) AS [Average], COUNT(DISTINCT ([o].[EmployeeID])) + COUNT(DISTINCT (CASE
34713473 WHEN [o].[EmployeeID] IS NULL THEN 1
3474+ ELSE CAST(NULL AS int)
34723475END)) AS [Count], COUNT_BIG(DISTINCT ([o].[EmployeeID])) + COUNT_BIG(DISTINCT (CASE
34733476 WHEN [o].[EmployeeID] IS NULL THEN 1
3477+ ELSE CAST(NULL AS int)
34743478END)) AS [LongCount], MAX([o].[OrderDate]) AS [Max], MIN([o].[OrderDate]) AS [Min], ISNULL(SUM(DISTINCT ([o].[OrderID])), 0) AS [Sum]
34753479FROM [Orders] AS [o]
34763480GROUP BY [o].[CustomerID]
@@ -4027,8 +4031,10 @@ public override async Task GroupBy_Property_Select_Distinct_Count_over_nullable_
40274031 """
40284032SELECT [c].[Country] AS [Key], COUNT(DISTINCT ([c].[Region])) + COUNT(DISTINCT (CASE
40294033 WHEN [c].[Region] IS NULL THEN 1
4034+ ELSE CAST(NULL AS int)
40304035END)) AS [Count], COUNT_BIG(DISTINCT ([c].[Region])) + COUNT_BIG(DISTINCT (CASE
40314036 WHEN [c].[Region] IS NULL THEN 1
4037+ ELSE CAST(NULL AS int)
40324038END)) AS [LongCount]
40334039FROM [Customers] AS [c]
40344040GROUP BY [c].[Country]
@@ -4043,16 +4049,35 @@ public override async Task GroupBy_Property_Select_Distinct_Count_over_nullable_
40434049 """
40444050SELECT [c].[Country] AS [Key], COUNT(DISTINCT (NULLIF([c].[Region], N'WA'))) + COUNT(DISTINCT (CASE
40454051 WHEN ([c].[Region] <> N'WA' OR [c].[Region] IS NULL) AND [c].[Region] IS NULL THEN 1
4052+ ELSE CAST(NULL AS int)
40464053END)) AS [Count], COUNT_BIG(DISTINCT (CASE
40474054 WHEN [c].[City] <> N'London' OR [c].[City] IS NULL THEN [c].[Region]
40484055END)) + COUNT_BIG(DISTINCT (CASE
40494056 WHEN ([c].[City] <> N'London' OR [c].[City] IS NULL) AND [c].[Region] IS NULL THEN 1
4057+ ELSE CAST(NULL AS int)
40504058END)) AS [LongCount]
40514059FROM [Customers] AS [c]
40524060GROUP BY [c].[Country]
40534061""" ) ;
40544062 }
40554063
4064+ public override async Task GroupBy_Property_Select_Distinct_Count_over_non_nullable_expression ( bool async )
4065+ {
4066+ await base . GroupBy_Property_Select_Distinct_Count_over_non_nullable_expression ( async) ;
4067+
4068+ AssertSql (
4069+ """
4070+ SELECT [c].[Country] AS [Key], COUNT(DISTINCT (COALESCE([c].[Region], N'unknown'))) AS [Coalesced], COUNT_BIG(DISTINCT (CASE
4071+ WHEN [c].[Region] IS NULL THEN N'none'
4072+ ELSE N'some'
4073+ END)) AS [Conditional], COUNT(DISTINCT (CASE
4074+ WHEN [c].[City] <> N'London' OR [c].[City] IS NULL THEN [c].[Region]
4075+ END)) + COUNT(DISTINCT (CAST(NULL AS int))) AS [NotNullFiltered]
4076+ FROM [Customers] AS [c]
4077+ GROUP BY [c].[Country]
4078+ """ ) ;
4079+ }
4080+
40564081 public override async Task GroupBy_Property_Select_Count_with_not_null_and_other_predicate ( bool async )
40574082 {
40584083 await base . GroupBy_Property_Select_Count_with_not_null_and_other_predicate ( async) ;
0 commit comments