Skip to content

fix(postgresql): shape typed filters' null checks as EF Core does - #126

Merged
CaffeinatedCoder merged 2 commits into
mainfrom
fix/118-null-check-shapes
Oct 20, 2026
Merged

CaffeinatedCoder merged 2 commits into
mainfrom
fix/118-null-check-shapes

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #118

Stacked on #124 (#117) → #123 (#94) → #122 (#80) → #121 (#101); merge those first.

Problem

#68 gave typed filters C#'s answer for null operands, in two shapes EF Core does not write for the same lambda. The rows were the same, but a partial index is provably usable by EF Core's query only when its predicate has the query's shape, and the parity sweep had to waive 300 rows for it:

Lambda Was (5.5.0 candidate) Is, as EF Core writes it
x.Name.ToLower() != "a" (string?) (lower("Name") <> 'a' OR lower("Name") IS NULL) (lower("Name") <> 'a' OR "Name" IS NULL)
(x.Name ?? x.Kind) != "a" (coalesce(…) <> 'a' OR coalesce(…) IS NULL) (coalesce(…) <> 'a' OR ("Name" IS NULL AND "Kind" IS NULL))
!(x.Maybe > 5) (int?) ("Maybe" <= 5 OR "Maybe" IS NULL) CASE WHEN "Maybe" > 5 THEN FALSE ELSE TRUE END

Change

Tests

🤖 Generated with Claude Code

@CaffeinatedCoder CaffeinatedCoder added this to the 5.5.0 milestone Oct 20, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working stacked Base is another open PR; merge in order, CI does not run until it targets main severity/low Cosmetic, message or documentation-level difference package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL area/indexes Complex-property, composite, unique and filtered indexes area/constraints Temporal (WITHOUT OVERLAPS, PERIOD) and exclusion constraints labels Oct 20, 2026
#68 gave typed filters C#'s answer for null operands, in two shapes EF
Core does not write for the same lambda: a computed operand was tested
itself (lower("Name") IS NULL where EF Core tests "Name" IS NULL;
coalesce(a, b) IS NULL where EF Core tests a IS NULL AND b IS NULL), and a
negated ordering comparison over a nullable operand became a disjunction
("Maybe" <= 5 OR "Maybe" IS NULL) where EF Core writes CASE WHEN
"Maybe" > 5 THEN FALSE ELSE TRUE END. The rows were the same, but a
partial index is provably usable by a query only in the query's shape.

Null checks are now written over the operand's nullable columns (every
function the translator accepts is strict; a coalesce is null only when
all its inputs are), and the negation is EF Core's CASE. Both shapes are
new in 5.5.0, so no released filter changes.

Verified with the change reverted: the parity sweep fails 300 rows (this
removes the #118 block from waivers.txt) and three filter tests fail.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/117-substring-captured-start branch from 9f23cec to 8f592d5 Compare October 20, 2026 06:35
@CaffeinatedCoder
CaffeinatedCoder force-pushed the fix/118-null-check-shapes branch from c6b7c37 to 0f329ec Compare October 20, 2026 06:35
@CaffeinatedCoder
CaffeinatedCoder changed the base branch from fix/117-substring-captured-start to main October 20, 2026 07:10
@CaffeinatedCoder
CaffeinatedCoder merged commit 9db0360 into main Oct 20, 2026
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/118-null-check-shapes branch October 20, 2026 07:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/constraints Temporal (WITHOUT OVERLAPS, PERIOD) and exclusion constraints area/indexes Complex-property, composite, unique and filtered indexes bug Something isn't working package/postgresql Affects EFCore.ComplexIndexes.PostgreSQL severity/low Cosmetic, message or documentation-level difference stacked Base is another open PR; merge in order, CI does not run until it targets main

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant