Query: optimize database null-semantics propagation
- Dominant language
- C#
- Stars
- 14.8k
- Forks
- 3.4k
- PR merge metrics
- PR metrics pending
Description
We can optimize some case block for nullability by letting expressions take care of it instead of doing explicit checks.
```csharp
db.Set().Select(
x => x.NullableStringA != null && x.NullableStringB != null
? x.NullableStringA + x.NullableStringB
: default)
```
translates to
```sql
SELECT CASE
WHEN "e"."NullableStringA" IS NOT NULL AND "e"."NullableStringB" IS NOT NULL
THEN "e"."NullableStringA" || "e"."NullableStringB"
ELSE NULL
END
FROM "Entities1" AS "e"
```
but ideally it should translate to
```sql
SELECT "e"."NullableStringA" || "e"."NullableStringB"
FROM "Entities1" AS "e"
```
This is in a sense the dual of pushing nullability information from clause test to clause result, but it also relies on clause/else matching; see #25977 for more cross-clause optimizations.
Contributor guide
Assessment
This issue has not been assessed yet.