Skip to content

feat: translate RangeSet.Count, on 10.x (port of #484, #495) - #499

Merged
CaffeinatedCoder merged 3 commits into
release/10.xfrom
feat/495-translate-rangeset-count-10.x
Oct 26, 2026
Merged

CaffeinatedCoder merged 3 commits into
release/10.xfrom
feat/495-translate-rangeset-count-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #495

Problem

RangeSet.Count runs as SQL on main since #484 (PR #491, merged as 848fc0f). On release/10.x it ran in memory only.

Change

Cherry-picked with -x: 2193825 and c6be2cb from PR #491.

  • Code: MultirangeCount, the placeholder in ValueRangesMemberTranslator inside a NULL CASE, and the expansion in the decorated processor.
  • Tests and oracles: RangeSetCountParityTests (an oracle) with the seed rangeset-count-of-a-null-multirange-is-zero, RangeSetCountTranslationTests, the fail-closed registration test, docs, claims E84, E85 and M06, translation-support.json and postgres-surface.json.
  • 10.x differences:
    • Process keeps 10.x's EmptyCollectionRewriter.Rewrite(…, TypeMappingSource) and wraps it in MultirangeCount.Expand.
    • 10.x has no sql-processor-reuses-its-first-output seed, so the refresh is left out.
    • oracles.json keeps 10.x's entries plus RangeSetCountParityTests.
    • The changelog rows go under [10.4.0].

Tests

On EF Core 10.0.0, PostgreSQL 16 and 18: conventions, no-database EF tests and the integration suite (331 tests). On the newest-patch leg: the Count, multirange and repeated-execution tests. The seed is caught on 10.x.

🤖 Generated with Claude Code

CaffeinatedCoder and others added 2 commits October 26, 2026 13:11
…484)

RangeSet.Count ran in memory only: PostgreSQL has no multirange cardinality
function, and #94's spike found a member translator can't build the subquery
(no alias manager). #478 showed the way: the member translator emits a
placeholder, and MultirangeCount builds (SELECT count(*)::int FROM unnest(x)
AS vcN(r)) after EF Core's alias pass, from the same decorated processor as
ValueSetSqlGuard, so it fails closed too.

count(*) over unnest(NULL) is 0, so the placeholder sits inside
CASE WHEN x IS NULL THEN NULL, which EF Core folds away for a required column.

RangeSetCountParityTests measures every range type. A stored multirange counts
as memory counts it, the extremes included. One the server computes from an
operand at the element type's extreme can hold a range memory reads as empty,
(,-2147483648) or (infinity,), the documented domain boundary; those rows are
set aside and counted, and docs/efcore.md says so.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 2193825)
…or seed (#484)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c6be2cb)
@CaffeinatedCoder CaffeinatedCoder added this to the 10.4.0 milestone Oct 26, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request area/range-set RangeSet and multirange algebra package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime labels Oct 26, 2026
@CaffeinatedCoder CaffeinatedCoder mentioned this pull request Oct 26, 2026
# Conflicts:
#	src/CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime/CHANGELOG.md
#	test/oracles/claims.json
@CaffeinatedCoder
CaffeinatedCoder merged commit 7525c3e into release/10.x Oct 26, 2026
10 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/495-translate-rangeset-count-10.x branch October 26, 2026 13:46
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 enhancement New feature or request package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL package/efcore-nodatime Affects CodoMetis.ValueRanges.EFCore.PostgreSQL.NodaTime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant