Skip to content

feat: translate value set Union, Add, Intersect and Except canonically, on 10.x (port of #478, #481) - #482

Merged
CaffeinatedCoder merged 4 commits into
release/10.xfrom
feat/481-canonical-set-operations-10.x
Oct 26, 2026
Merged

CaffeinatedCoder merged 4 commits into
release/10.xfrom
feat/481-canonical-set-operations-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #481

Port of #478 (PR #480, merged into main as 46c31df) to release/10.x, for 10.4.0 (#472). Fixed only on this branch, so #481 is closed by hand after the merge.

Problem

On this line Intersect, Except and Add on value sets run in memory only, and a Union is array_cat, refused under equality, Count, GroupBy, Distinct, OrderBy, set operations, IN and ExecuteUpdate for every family.

Change

  • Cherry-picks (-x) of the four commits of feat: translate value set Union, Add, Intersect and Except canonically for every family but text (#478) #480:
    • 04505a2 ← e5be805: ISetTypeDefinition.CanonicalizesInSql, the placeholders in ValueSetsMethodCallTranslator, ValueSetSqlGuard.CanonicalExpander, and the translation tests.
    • 0550e39 ← 571e82c: CanonicalSetOperationParityTests (an oracle, with the seed canonical-set-keeps-any-copy), CanonicalSetCompositionTests, and the NULL-operand parity extended to the four operations.
    • e182a6f ← c2946fa: the docs, AGENTS.md, claims E17–E20, E35, E75 and E78–E82, translation-support.json and the changelogs.
    • da0aad5 ← 18c264f: Add binds a Coptic-calendar element as the set stores it.
  • Conflicts: only from context that differs between the lines.
    • ValueRangesParameterBasedSqlProcessorFactory: this line's EmptyCollectionRewriter.Rewrite takes the type mapping source too; both arguments are kept.
    • sql-processor-reuses-its-first-output.patch doesn't exist here (its oracle, RepeatedExecutionProbeTests, is main's), so its regeneration is dropped.
    • The changelog rows go under [10.4.0] here, instead of main's [11.0.0-preview.1]. In the EF Core and EF Core NodaTime changelogs they replace "No change in this package." main's edit to a Fixed line of the unreleased preview has no counterpart here, and no released section changes.
  • Same SQL: the Translate value set Intersect, Except, Add and a canonical Union for the non-text families with composed SQL #478 spike built the guard code on EF Core 10 and 11 with identical SQL and results; nothing in it needed changing for this line.

Tests

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

  • Suites: core 1,399, NodaTime 239, EF translation 392, NodaTime EF translation 113, conventions 420, ASP.NET Core 92. All passed.
  • Integration: with 4 test workers, the main project 317 and the infinity-disabled project 5 on PostgreSQL 16 and on 18, including CanonicalSetOperationParityTests, CanonicalSetCompositionTests, ValueSetNullOperandParityTests and TranslationSupportProbeTests. All passed.
  • Seed applied: TheFirstCopyOfEachValue_IsKept_AsInMemory fails with 12 rows, DecimalSet and DecimalSet<Money> keeping 1.00 where memory keeps 1.0.
  • Newest patch: the EF Core 10.0.13 / Npgsql EF 10.0.3 leg is CI's.

🤖 Generated with Claude Code

CaffeinatedCoder and others added 4 commits October 26, 2026 11:26
…y for the non-text families (#478)

For every family PostgreSQL sorts as memory does, the translator emits a
placeholder per operation inside the NULL-over-NULL CASE, and the SQL guard
builds it after EF Core's alias pass: ARRAY((SELECT DISTINCT ON (x) x FROM
unnest(...) WITH ORDINALITY ... WHERE x IS NOT NULL ORDER BY x, ordinality)),
or the multiset form under @>, <@, &&, IsEmpty, a null test and the outermost
projection. Text keeps array_cat and the refusals (#479).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit e5be805)
#478)

CanonicalSetOperationParityTests runs Union, Add, Intersect and Except over
every pair of subsets of three probes for every family but text, stored
canonical, out of order and twice, and with a NULL element, under ==, Count,
ExecuteUpdate, the projection, containment and IsEmpty; and the copy of a value
kept, for decimals by scale and floats by the sign of zero. The seed
canonical-set-keeps-any-copy (a plain DISTINCT) is caught by it.
CanonicalSetCompositionTests runs the compositions text still refuses, and the
NULL-operand parity covers the new operations.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 571e82c)
…ut text (#478)

The EF guide, the value sets guide, getting started and the four package
READMEs say where the operations now run, that equal values keep the first
copy, what a NULL element another tool stored does, and that a wrapper's
CompareTo must order as its underlying type does. AGENTS.md narrows the
array_cat rule to text and adds the rule for canonical form; claims E17-E20,
E35 and E75 follow, E78-E82 are new; the translation inventory and three
changelogs record the change.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit c2946fa)
…et rewrites (#478)

Co-Authored-By: Claude Opus 5.5 <[email protected]>
(cherry picked from commit 18c264f)
@CaffeinatedCoder CaffeinatedCoder added this to the 10.4.0 milestone Oct 26, 2026
@CaffeinatedCoder CaffeinatedCoder added enhancement New feature or request 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 labels Oct 26, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit cbdeca8 into release/10.x Oct 26, 2026
10 of 11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the feat/481-canonical-set-operations-10.x branch October 26, 2026 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/value-sets Value set families and wrapper arities 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