Skip to content

fix: value set Union and Remove over a NULL operand are NULL in a query, on 10.x (port of #360, #395) - #445

Merged
CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/395-value-set-null-operand-10.x
Oct 25, 2026
Merged

CaffeinatedCoder merged 1 commit into
release/10.xfrom
fix/395-value-set-null-operand-10.x

Conversation

@CaffeinatedCoder

Copy link
Copy Markdown
Owner

Closes #395

Port of #360 (PR #443), cherry-picked with -x.

Problem

The same defect as #360, on release/10.x: a value set Union (array_cat) and Remove (array_remove) were declared NULL exactly when an operand is NULL, but neither function is strict. So a projection loaded the other operand (r.MaybeTags.Union(o) loaded o for a NULL MaybeTags, r.Tags.Remove(r.Label) loaded Tags for a NULL Label) while Where(… == null) selected the row. 10.2.0 named it under docs/efcore.md#known-differences-in-1020.

Change

Tests

  • On .NET 10 (SDK 10.0.402), PostgreSQL 16: the full EFCore.PostgreSQL.IntegrationTests suite (302), the EF translation tests (330) and the conventions tests (420) pass. dotnet run tools/oracles.cs seeds catches the seed on this line.
  • With the ValueSetsMethodCallTranslator change reverted to release/10.x's file, both ValueSetNullOperandParityTests tests fail for the expected reason, e.g. r.MaybeTags.Union(r.Tags) Select, row 1: server {a,b}, rule (c) NULL.

🤖 Generated with Claude Code

…ry (#360)

array_cat and array_remove aren't strict: array_cat(NULL, '{z}') is {z} and
array_remove('{a}', NULL) is {a}. Both were declared as propagating
nullability, so a filter's `== null` selected the row while a projection
loaded the other operand.

Each call is now CASE WHEN a IS NULL OR b IS NULL THEN NULL ELSE f(a, b) END,
with the function declared as propagating nothing and never NULL (it is
reached only with both operands non-NULL). EF Core folds the test away for a
required column, a non-null parameter and a constant, so their SQL is the
bare call. ValueSetSqlGuard follows the union through the CASE as before.

ValueSetNullOperandParityTests holds it on every route to a NULL operand,
registered as an oracle with a seed; the 24 candidates the composition
sweeps had registered against #360 are removed.

(cherry picked from commit 9b5ed69)

Ported to release/10.x for #395. The changelog row goes under [10.3.0]
### Changed answers and the migration text under Changed answers in
10.3.0; the 10.2.0 known difference is removed, and the seed names
ValueSetNullOperandParityTests alone, since this line has none of the
composition sweeps.

Found-By: OT
Defect-Class: SQL
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 bug Something isn't working silent Answers wrongly without throwing — fixes go in the next major, never deferred area/value-sets Value set families and wrapper arities package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL severity/low Cosmetic, message or documentation-level difference labels Oct 25, 2026
@CaffeinatedCoder
CaffeinatedCoder merged commit 930475a into release/10.x Oct 25, 2026
10 of 11 checks passed
@CaffeinatedCoder
CaffeinatedCoder deleted the fix/395-value-set-null-operand-10.x branch October 25, 2026 16:59
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 bug Something isn't working package/efcore Affects CodoMetis.ValueRanges.EFCore.PostgreSQL severity/low Cosmetic, message or documentation-level difference silent Answers wrongly without throwing — fixes go in the next major, never deferred

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant