Skip to content

fix: a range factory over a NULL element is NULL in a query (10.x, #388) - #394

Merged
CaffeinatedCoder merged 2 commits into
release/10.xfrom
fix/388-factories-over-null-10.x
Oct 25, 2026
Merged

CaffeinatedCoder merged 2 commits into
release/10.xfrom
fix/388-factories-over-null-10.x

Conversation

@CaffeinatedCoder

@CaffeinatedCoder CaffeinatedCoder commented Oct 24, 2026 •

Copy link
Copy Markdown
Owner

Closes #388

This is the 10.x port of #382 for 10.2.0 (#358). It is git cherry-pick -x of 5cf3845 from PR #392. It was stacked on PR #393 (#387), which has merged.

Problem

Over a NULL element, the translated CreateFinite gave empty and CreateUnboundedStart/CreateUnboundedEnd gave (,), instead of NULL. So DateRange.CreateUnboundedEnd(b.Visit!.From).Contains(v) selected a booking without a visit: a positive filter answering wrongly.

Change

Tests

  • With only this commit's fix stripped, exactly two tests fail: NullOperandTranslationTests.ARangeFactoryOverANullableElement_IsNull (SQL pins) and the new live test. With the fix, both pass.
  • Every suite outside the integration projects passes on the floor.
  • Both integration projects pass on PostgreSQL 16, on EF Core 10.0.0 and on 10.0.13 (289 + 4 tests on each leg). After the added test, NullElementTests (5 tests) passes on both legs again.

Closes doesn't act on release/10.x, so close #388 by hand after the merge.

🤖 Generated with Claude Code

CreateFinite fell into its inverted-bounds guard and gave empty, and
CreateUnboundedStart/End passed the NULL to PostgreSQL's range
constructor, which reads a NULL bound as unbounded and gave (,). So
Contains(v) was true for a row without the element: the optional side
of an outer join, or a nullable column read with .Value. The factories
are now CASE WHEN e IS NULL THEN NULL ELSE <translation> END, which EF
Core folds away for required elements, non-null parameters and
constants.

Found-By: OT
Defect-Class: SQL

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 5cf3845)
@CaffeinatedCoder CaffeinatedCoder added this to the 10.2.0 milestone Oct 24, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred area/ranges Range unions, variants and the shape engines package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime severity/medium Inconsistency or failure in a narrow scenario stacked Base is another open PR; merge in order, CI does not run until it targets main labels Oct 24, 2026
Base automatically changed from fix/387-null-element-contains-10.x to release/10.x October 24, 2026 20:46
#387, #388)

On main the composition sweeps hold #381 and #382 over every shape; this
line has none of them. Adds the cases the release review named: a bool
projection of RangeSet.Contains, and a range factory over a NULL element
consumed by Contains in a projection, by Overlaps in a filter, its
negation and a projection, and by All over a captured list.

Each new assertion fails with the translator from before #382's fix
(and the RangeSet projection with the one from before #381's).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@CaffeinatedCoder
CaffeinatedCoder merged commit f50caf3 into release/10.x Oct 25, 2026
11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/388-factories-over-null-10.x branch October 25, 2026 09:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ranges Range unions, variants and the shape engines bug Something isn't working package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime severity/medium Inconsistency or failure in a narrow scenario silent Answers wrongly without throwing — fixes go in the next major, never deferred 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.

1 participant