Repository navigation
feat: translate Length on Int32Range and Int64Range, on 10.x (port of #405, #438) - #439
Merged
CaffeinatedCoder merged 1 commit intoOct 25, 2026
Conversation
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]>
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #438
Port of #405 (PR #437, merged into
mainas 67628e2) torelease/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
LengthonInt32RangeandInt64Rangeruns in memory only, so a query can't filter or order by it.Change
8743d03: cherry-pick of 596766d (-x):ValueRangesMemberTranslatorand the publicValueRangesMemberTranslatorPlugin, with its registration.IntegerLengthTranslationTests,IntegerLengthParityTestsand its seed.DecimalRange.Length.translation-support.json, claims E31 and E73,docs/efcore.md#what-runs-where,docs/ranges.mdand the EF Core README.oracles.json, all from context that differs between the lines.[10.3.0]### Addedhere, instead ofmain's[11.0.0-preview.1]. In the EF Core changelog that section had no### Addedyet.oracles.jsongets only this change'sIntegerLengthParityTestsentry.IntegerLengthParityTestsruns on 10.x: translation-support inventory, every public query member classified and probed (port of #384) #430'sComposition/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.xwith SDK 10.0.402 and EF Core 10.0.0:IntegerLengthParityTestsandTranslationSupportProbeTestswith both members classifiedserver. All passed.🤖 Generated with Claude Code