Skip to content

feat: translate Clamp on Int32Range, Int64Range and DecimalRange, on 10.x (port of #406, #441) - #442

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
feat/441-translate-clamp-10.x
Oct 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
feat/441-translate-clamp-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #441

Port of #406 (PR #440, merged into main as 84dc121) to release/10.x, for 10.3.0 (#408). Fixed only on this branch, so #441 is closed by hand after the merge.

Problem

On this line Clamp runs in memory only on every range type, so a query can't filter or order by a clamped value.

Change

  • 5c17d43: cherry-pick of 5ffc7b6 (-x):
    • The Clamp arm in ValueRangesMethodCallTranslator, for Int32Range, Int64Range and DecimalRange.
    • ClampTranslationTests, ClampParityTests and its seed.
    • The client-only tests moved to DateRange.Clamp.
    • translation-support.json's except map, claims E31 and E74, docs/efcore.md#what-runs-where, docs/ranges.md and the EF Core README.
  • The changelog rows landed under [10.3.0] ### Added, after the Length row from 10.x: translate Length on Int32Range and Int64Range (port of #405) #438, in both changelogs.
  • The only conflict was oracles.json, from context that differs between the lines. It gets only the ClampParityTests entry.

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 330, NodaTime EF translation 91, ASP.NET Core 92. Both integration projects on PostgreSQL 16 and 18: 300 and 4 each, including ClampParityTests and TranslationSupportProbeTests. All passed.
  • Seed applied: the parity test fails on the rows whose value lies above a discrete range.
  • Clamp arm removed: the 3 translation tests fail, and every parity call is "Untranslated".
  • Newest patch: the EF Core 10.0.13 / Npgsql EF 10.0.3 leg is CI's (local float restores fail 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

Clamp(value) ran in memory only. On the three types whose bounds read as
memory's it now runs as SQL with memory's answers:

  CASE WHEN x IS NULL OR v IS NULL OR isempty(x) THEN NULL
       ELSE LEAST(GREATEST(v, lower(x)), <upper>) END

where <upper> is the bound UpperBound() reads: upper(x) - 1 on int4range and
int8range, whose stored upper bound is exclusive, and upper(x) on numrange,
where memory returns an exclusive bound as it is. GREATEST and LEAST skip the
NULL an unbounded side gives, so a NULL range or value is tested first and
answers NULL (rule (c)). Measured on PostgreSQL 16, the extremes included.

Clamp on the other range types stays in memory. ClampParityTests holds every
condition on #408's parity list; translation-support.json classifies the
three closed types server through its except map, and the docs move the row.

(cherry picked from commit 5ffc7b6)

Ported to release/10.x for #441. 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 f83dc29 into release/10.x Oct 25, 2026
10 of 12 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/441-translate-clamp-10.x branch October 25, 2026 15:51
@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