Special-case coalescing of SUM in SqlNullability is causing issues #28158
Labels
area-query
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-enhancement
Milestone
In my eternal quest to translate all aggregate functions on the planet (and beyond), I'm adding support for Sum and Average over TimeSpan for PostgreSQL, where that's supported (npgsql/efcore.pg#2339).
For sum, I ran into trouble because of the following code in SqlNullabilityProcessor:
This fails because it attempts to coalesce TimeSpan (non-numeric) to zero.
Replacing the 0 with
Activator.CreateInstance(sqlFunctionExpression.Type)
makes the problem go away. However, since I'm translating EF.Functions.Sum, the return type of that function is nullable (TimeSpan?
), since that's how SQL sum behaves (compare with #26634). So the COALESCE introduced here is unwanted.It generally seems better to handle this kind of thing in the method translator (but I don't have the context) - is that possible?
/cc @maumar @smitpatel
The text was updated successfully, but these errors were encountered: