Skip to content

10.x: the range factories over a NULL element build a range instead of answering NULL (port of #382) #388

Open

Description

@CaffeinatedCoder

Problem

The same defect as #382, on release/10.x. When an element argument is NULL, the translated CreateFinite, CreateUnboundedStart and CreateUnboundedEnd still build a range. CreateFinite falls into its inverted-bounds guard and gives empty. The other two pass the NULL to PostgreSQL's range constructor, which reads a NULL bound as unbounded and gives (,). So even a positive filter selects a row that has no element: DateRange.CreateUnboundedEnd(b.Visit!.From).Contains(v) is true for a booking without a visit. EF Core answers NULL for its own value-producing members (b.Visit!.From.AddDays(1)).

Rule (c)'s predicate wrapper (#357) can't catch this, because daterange(NULL, NULL, '[)') IS NOT NULL is true. GuardedFiniteRangeConstructor and RangeConstructor are the same on both lines.

Change

Cherry-pick the #382 fix with -x, with its regression test. When an element argument can be NULL, the translation becomes CASE WHEN a IS NULL OR b IS NULL THEN NULL ELSE <today's translation> END, declared nullable. Required arguments keep today's SQL. It's SQL only: in memory the call can't be made.

The probes that found it (OuterJoinProbeTests, PR #383) are on main only, so the port's own test has to cover a value, == null, IsEmpty() and Contains(v).

Release

silent: one row under ### Changed answers in ## [10.2.0], linking this issue and its entry under docs/migration.md#changed-answers-in-1020. Fixed only on release/10.x, so close it by hand (#365).

Activity

  1. added this to the 10.2.0 milestone on Oct 24, 2026
  2. added
    bugSomething isn't working
    silentAnswers wrongly without throwing — fixes go in the next major, never deferred
    area/rangesRange unions, variants and the shape engines
    package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQL
    severity/mediumInconsistency or failure in a narrow scenario
    on Oct 24, 2026
  3. CaffeinatedCoder commented on Oct 24, 2026

    @CaffeinatedCoder
    OwnerAuthor

    PR #394 (stacked on PR #393) cherry-picks the #382 fix (PR #392) with -x, and adds NullElementTests.RangeFactories_OverANullElement_AreNull. With the fix stripped, that test and the SQL pins fail.

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/rangesRange unions, variants and the shape enginesbugSomething isn't workingpackage/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLseverity/mediumInconsistency or failure in a narrow scenariosilentAnswers wrongly without throwing — fixes go in the next major, never deferred

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions