Skip to content

feat: translate Length on Int32Range and Int64Range, on 10.x (port of #405, #438) - #439

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
feat/438-translate-integer-length-10.x
Oct 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
feat/438-translate-integer-length-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #438

Port of #405 (PR #437, merged into main as 67628e2) to release/10.x, for 10.3.0 (#408). Fixed only on this branch, so #438 is closed by hand after the merge.

Problem

On this line Length on Int32Range and Int64Range runs in memory only, so a query can't filter or order by it.

Change

  • 8743d03: cherry-pick of 596766d (-x):
    • ValueRangesMemberTranslator and the public ValueRangesMemberTranslatorPlugin, with its registration.
    • IntegerLengthTranslationTests, IntegerLengthParityTests and its seed.
    • The client-only tests moved to DecimalRange.Length.
    • translation-support.json, claims E31 and E73, docs/efcore.md#what-runs-where, docs/ranges.md and the EF Core README.
  • Conflicts: only in the two changelogs and oracles.json, all from context that differs between the lines.
    • The changelog row goes under [10.3.0] ### Added here, instead of main's [11.0.0-preview.1]. In the EF Core changelog that section had no ### Added yet.
    • oracles.json gets only this change's IntegerLengthParityTests entry.
  • Parity coverage: IntegerLengthParityTests runs on 10.x: translation-support inventory, every public query member classified and probed (port of #384) #430's Composition/ helpers, which are already here. This line has none of the composition sweeps, so the test carries Epic: 10.3.0 #408's parity list itself.

Tests

Run on release/10.x with SDK 10.0.402 and EF Core 10.0.0:

  • Suites: core 1,399, NodaTime 239, conventions 420, EF translation 327, NodaTime EF translation 91, ASP.NET Core 92. Both integration projects on PostgreSQL 16 and 18: 298 and 4 each, including IntegerLengthParityTests and TranslationSupportProbeTests with both members classified server. All passed.
  • Seed applied: the parity test fails with "server NULL, rule (c) 0" on the empty rows.
  • Plugin unregistered: the 4 translation tests fail, and every parity call is "Untranslated, where it must run as SQL".
  • Newest patch: the EF Core 10.0.13 / Npgsql EF 10.0.3 leg is CI's. Local float restores have been failing intermittently on this machine (see test: map each translator operand from its declared type, and sweep for it, on 10.x (port of #295, #433) #435).

🤖 Generated with Claude Code

Length on the two integer ranges ran in memory only, so a query could not
filter or order by it. It now runs as SQL with memory's answers:

  Int32Range: CASE WHEN isempty(x) THEN 0
              ELSE upper(x)::bigint - lower(x)::bigint END
  Int64Range: CASE WHEN isempty(x) THEN 0
              WHEN upper(x)::numeric - lower(x)::numeric <= 9223372036854775807
              THEN (upper(x)::numeric - lower(x)::numeric)::bigint END

PostgreSQL stores an integer range as [lower, upper), so upper - lower is
the count memory returns. An unbounded side and a NULL range give NULL, and
an Int64Range count above long.MaxValue gives NULL rather than an int8
overflow, as in memory. Measured on PostgreSQL 16 over columns, parameters
and inlined constants.

ValueRangesMemberTranslator matches the two members by identity and is
registered through a new public ValueRangesMemberTranslatorPlugin.
IntegerLengthParityTests holds every condition on #408's parity list against
memory over the loaded rows; translation-support.json classifies both server
and the docs move the row.

(cherry picked from commit 596766d)

Ported to release/10.x for #438. The changelog row goes under [10.3.0].

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@CaffeinatedCoder CaffeinatedCoder added this to the 10.3.0 milestone Oct 25, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request area/ranges Range unions, variants and the shape engines package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL labels Oct 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit e022712 into release/10.x Oct 25, 2026
10 of 12 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/438-translate-integer-length-10.x branch October 25, 2026 15:15
@CaffeinatedCoder CaffeinatedCoder mentioned this pull request Oct 25, 2026
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 enhancement New feature or request package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant