Skip to content

EF Core 11 reads an empty captured collection as a bare NULL that PostgreSQL types as text: operator does not exist: text && int4range #290

Closed

Description

@CaffeinatedCoder

Problem

EmptyCollectionRewriter (#137) gave an empty captured collection of ranges or value sets, sent one parameter per element, a one-row VALUES of typed NULLs under WHERE FALSE, because EF Core 10.0.0's SQL generator refused an empty VALUES. EF Core 11's SqlNullabilityProcessor replaces the empty VALUES parameter itself (dotnet/efcore#37216; behind a switch in a 10.0.x patch), before the plugin's pass runs, with

FROM (SELECT NULL AS "Value" WHERE FALSE) AS w WHERE w."Value" && b."Seats"

The NULL is bare: Npgsql writes a null constant without its type, PostgreSQL types it as text, and the query fails on the server:

Npgsql.PostgresException: 42883: operator does not exist: text && int4range

On net11.0 this fails RangeCollectionContainsTests.AnEmptyCollection*, SetCollectionContainsTests.AnEmptyCollection_*, Ranges_AnswerAsInMemory (416 rows) and ValueSets_AnswerAsInMemory (1088 rows): every Any/Count over an empty captured list of ranges or sets throws, where 10.x answers false/0. The old rewriter never sees the empty VALUES on EF Core 11 and is a no-op there. Loud, not silent.

Change

The rewriter matches EF Core 11's shape — a table-less SELECT of null constants under WHERE FALSE — and casts each constant whose type is a registered range or set type to its store type (NULL::int4range), the mapping EF Core already attached from the parameter's element mapping. Other types keep EF Core's SQL (EmptyCollectionGuardTests). Translation tests pin the new SQL; the integration tests of the answers are unchanged.

Found by the #103 retarget's first test run.

Activity

  1. added this to the 11.0.0 milestone on Oct 19, 2026
  2. added
    choreBuild, CI, packaging, refactoring with no behaviour change
    area/range-setRangeSet and multirange algebra
    area/value-setsValue set families and wrapper arities
    package/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQL
    on Oct 19, 2026
  3. changed the title [-]EF Core 11 reads an empty captured collection itself: remove `EmptyCollectionRewriter`[/-] [+]EF Core 11 reads an empty captured collection as a bare NULL that PostgreSQL types as `text`: `operator does not exist: text && int4range`[/+] on Oct 19, 2026
  4. added
    bugSomething isn't working
    severity/highWrong results, crash or failed writes in a realistic scenario
    and removed
    choreBuild, CI, packaging, refactoring with no behaviour change
    on Oct 19, 2026
  5. CaffeinatedCoder commented on Oct 19, 2026

    @CaffeinatedCoder
    OwnerAuthor

    "Behind a switch in a 10.0.x patch" is EF Core 10.0.2 and later: dotnet/efcore#37248 (milestone 10.0.2) backported #37216, and Microsoft.EntityFrameworkCore.Issue37216 first appears in the 10.0.2 Relational assembly. Npgsql EF 10.0.1–10.0.3 require EF Core ≥ 10.0.4, so the 10.x line fails today for every consumer on a current provider, not when some future patch ships. Measured 2026-10-19 on the 10.0.0 code with EF Core 10.0.13 / Npgsql EF 10.0.3: the same 4 translation and 5 integration failures as here, every 42883 shape, and the off switch restores the 10.0.0 behaviour completely. Filed as #302 under the 10.0.1 epic (#296); the 10.x port has to keep the empty-VALUES path for the floor, which this fix dropped because EF Core 11 never produces it.

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/range-setRangeSet and multirange algebraarea/value-setsValue set families and wrapper aritiesbugSomething isn't workingpackage/efcoreAffects CodoMetis.ValueRanges.EFCore.PostgreSQLseverity/highWrong results, crash or failed writes in a realistic scenario

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions