Invalid SQL generated when using Null Coalescing Operator on bool for the SQLServer provider #27176
Labels
area-query
consider-for-current-release
customer-reported
punted-for-7.0
Originally planned for the EF Core 7.0 (EF7) release, but moved out due to resource constraints.
type-bug
Milestone
Given the following
When I execute the following query:
The generated sql is wrong:
The second argument of the
COALESCE
function will never be picked even if[v0].[Approved]
is null due to theCASE WHEN ... THEN ... ELSE ... END
statement always evaluating to a non-null value.The Sqlite provider generates a good sql that works:
As a workaround, the query can be written as:
Where the following good sql is produced:
A working runnable repro is available here: https://github.com/alaatm/EFCoreIssueNullableBool
EF Core version: 6.0.1
Database provider: Microsoft.EntityFrameworkCore.SqlServer
Target framework: (e.g. .NET 6.0.1)
The text was updated successfully, but these errors were encountered: