Repository navigation
Description
Problem
The fixes for #302 (10.x) and #290 (11 line) type the plugin's NULLs by recognising EF Core's output shapes. EmptyCollectionRewriter matches a table-less SELECT … WHERE FALSE whose projections are all NULL constants, and on 10.x also the older empty VALUES. The root cause is lower down: Npgsql writes a null constant without its type, and PostgreSQL resolves a bare NULL as text against the polymorphic range and array operators (42883).
Matching the shape has two costs:
- Any other place where EF Core puts a range- or set-typed
NULLconstant into SQL hits the same42883, and the rewriter doesn't see it. EF Core already changed this shape once in a patch (EF Core 10: InvalidOperationException doing primitive list join when list is empty dotnet/efcore#37216), and 10.x:Any/Countover an empty captured list of ranges or value sets fails with42883: operator does not exist: text && int4rangeon EF Core 10.0.2 and later (dotnet/efcore#37216) #302 was found by a failing consumer query, not by a test. - Everything of the plugin's type in that projection is cast, including a column EF Core typed wrongly. That is main: the empty-root rewrite casts EF Core's
_ordcolumn to the range type (NULL::int4range AS _ord) #319 / 10.x: the empty-root rewrite casts EF Core's_ordcolumn to the range type on EF Core 10.0.2 and later (port of #319) #325's_ord.
Found by the 10.1.0 review on 2026-10-19 (as an altitude finding).
Question
Can the plugin's range and set type mappings write a typed null literal themselves (NULL::int4range, NULL::text[])? Then every null constant of the plugin's types would be typed wherever it appears, and the rewriter would reduce to the empty-VALUES case EF Core 10.0.0/10.0.1 needs. To answer it:
- Read where Npgsql renders a null constant (whether
GenerateSqlLiteral(null)reaches the mapping, or the generator writesNULLitself). - Check what a typed null changes elsewhere:
IS NULL,COALESCEandCASEbranches,ExecuteUpdatesetters, and theto_jsonb(NULL)refusal whose message says theNULLis untyped (fix: name the property path when refusing a value set setter written through jsonb_set_lax (10.x) #313). - Run the integration suites on both lines and on the floor and newest-patch legs.
Release
Internal; no answer should change. If it is done, on both lines.
Activity
CaffeinatedCoder commentedon Nov 30, 2026
Pre-11.0.0 review (2026-11-30, main @ 7c0e11b): assessment.
Query/EmptyCollectionRewriter.csis still the shape matcher, andValueRangesParameterBasedSqlProcessorFactorystill wires it. The question in this issue is still open: does Npgsql'sGenerateSqlLiteral(null)reach the plugin's mapping? Nobody has measured it yet.Proposal. Spike first, half a day:
GenerateNonNullSqlLiteral's null twin, orSqlConstantExpressionrendering through the mapping, in one range mapping. RunEmptyCollection*andExecuteUpdateJsonTestson PG 16 and 18.NULLitself, without asking the mapping, this issue needs an upstream change in efcore.pg, so close it and link the upstream issue.NULL::<store type>inValueRangeTypeMappingand the set mappings. Then shrink the rewriter to the EF Core 10.0.0/10.0.1 emptyVALUEScase. On main (EF Core 11 floor, main: move the EF Core and Npgsql floors to 11.0.0 #533) the rewriter may be removable altogether.to_jsonb(NULL)refusal message (fix: name the property path when refusing a value set setter written through jsonb_set_lax (10.x) #313).Breaking: no, but it changes SQL text wherever a NULL of the plugin's types appears, so every translation test that asserts on
NULLmoves. Effort: L. It needs the spike and both lines, and the integration suites on floor and newest-patch legs.Milestone: 11.0.0, the maintainer's decision of 2026-11-30. Of the three refactorings, this one carries the most risk: run the spike early so a "not possible upstream" result doesn't surface late, and land it after #152's two-line CI matrix if it can.
feat: write a typed NULL, and set a nullable property in a JSON colum…
test: a NULL range set bridges to a typed NULL array since #327 (#643)
Merge pull request #643 from CaffeinatedCoder/chore/327-typed-null