Skip to content

Typed filters: null checks over a computed operand and negated nullable comparisons are shaped unlike EF Core's #118

Closed

Description

@CaffeinatedCoder

Problem

Typed filters keep C#'s answer for null operands since #68, but two of the shapes they use differ from what EF Core writes for the same lambda. The rows are the same; the predicate is not, so a partial index is not provably usable by EF Core's query for that lambda, and the parity sweep (#101) has to waive each such row.

Lambda Package (5.5.0 candidate) EF Core
x.Name.ToLower() != "a" (string? Name) (lower("Name") <> 'a' OR lower("Name") IS NULL) lower("Name") <> 'a' OR "Name" IS NULL
(x.Name ?? x.Alias) != "a" (both string?) (coalesce("Name", "Alias") <> 'a' OR coalesce("Name", "Alias") IS NULL) COALESCE("Name", "Alias") <> 'a' OR ("Name" IS NULL AND "Alias" IS NULL)
!(x.Count < 5) (int? Count) ("Count" >= 5 OR "Count" IS NULL) CASE WHEN "Count" < 5 THEN FALSE ELSE TRUE END

EF Core tests the nullable columns under a computed operand (a strict function is null exactly when its nullable input is; a COALESCE when all of its inputs are), and writes a negated comparison over a nullable operand as a CASE.

Fix

Write the null checks over the operand's nullable columns, and the negation of a comparison over a nullable operand as EF Core's CASE. Both shapes are new in 5.5.0 (#68), so no released filter changes.

Found by the translator parity sweep (#101).

Activity

  1. added this to the 5.5.0 milestone on Oct 20, 2026
  2. added
    bug
    severity/low
    package/postgresql
    area/indexes
    area/constraints
    on Oct 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/constraintsarea/indexesbugpackage/postgresqlseverity/low

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions