Skip to content

fix: keep EF Core's _ord column an integer in the empty-root rewrite (10.x, #325) - #390

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/325-ord-cast-10.x
Oct 24, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/325-ord-cast-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #325

This is the 10.x port of #319 for 10.2.0 (#358). It is git cherry-pick -x of 474fc44 from PR #389.

Problem

On EF Core 10.0.2 and later, EF Core replaces an empty captured list with its own SELECT … WHERE FALSE (dotnet/efcore#37216). TypeTheNulls then cast EF Core's _ord ordering column to the range type, along with the element column:

SELECT NULL::int4range AS _ord, NULL::int4range AS "Value"
WHERE FALSE

It is latent: no answer changed. But a shape comparing _ord with an integer would have failed on the server, and only for the empty list. On the EF Core 10.0.0 floor, OneRowOfNulls already writes 0.

Change

  • EmptyCollectionRewriter.TypeTheNulls: _ord becomes 0, the same code change as on main.
  • Conflict resolution: this branch's remarks describe the two EF Core paths separately, so the _ord sentence goes into the 10.0.2-and-later paragraph.
  • The test pins both paths through EmptyCollectionSql.EfCoreReplacesTheEmptyValues: the floor's VALUES (0, NULL::int4range), and the patch's SELECT 0 AS _ord, NULL::int4range ….
  • A ### Fixed row under [10.2.0] in the root changelog and the EF Core package's changelog. The row says "on EF Core 10.0.2 and later".

Tests

  • FirstOrDefault_OverAnEmptyCapturedList_KeepsTheOrderingColumnAnInteger passes on the floor (EF Core 10.0.0) and on -p:EfFloat=10.0.13 -p:NpgsqlEfFloat=10.0.3.
  • On 10.0.13, with the fix stripped, it fails with actual: … SELECT NULL::int4range AS _ord …. On the floor it can't fail that way, because the floor never reaches TypeTheNulls.
  • Every suite outside the integration projects passes on the floor: unit, NodaTime, EF translation, AspNetCore and conventions.
  • Live, on PostgreSQL 16 with EF Core 10.0.13: RangeCollectionContainsTests, SetCollectionContainsTests and CapturedCollectionProbeTests (28 tests).

Closes #325 doesn't act on release/10.x, so the issue is closed by hand after the merge.

🤖 Generated with Claude Code

…319)

EF Core types the _ord ordering column of its empty query root like the
elements, so TypeTheNulls cast it to the range type with them
(NULL::int4range AS _ord). It is an integer when the list has elements,
so a shape comparing it with one would fail on the server for the empty
list only. Write it as 0, as OneRowOfNulls does on release/10.x.

Found-By: RV
Defect-Class: SQL

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 474fc44)
@CaffeinatedCoder CaffeinatedCoder added this to the 10.2.0 milestone Oct 24, 2026
@CaffeinatedCoder CaffeinatedCoder added bug Something isn't working area/range-set RangeSet and multirange algebra area/value-sets Value set families and wrapper arities package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime severity/low Cosmetic, message or documentation-level difference labels Oct 24, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 9af5842 into release/10.x Oct 24, 2026
10 of 12 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/325-ord-cast-10.x branch October 24, 2026 20:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/range-set RangeSet and multirange algebra area/value-sets Value set families and wrapper arities bug Something isn't working package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime severity/low Cosmetic, message or documentation-level difference

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant