You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
main: the empty-root rewrite casts EF Core's _ord column to the range type (NULL::int4range AS _ord) #319
EmptyCollectionRewriter casts every NULL constant of EF Core's empty query root whose CLR type is a registered range or value set type. EF Core gives the constant of its _ord ordering column that type too, so _ord is cast to the range type. Measured on main at 5f08625 with a translation probe:
SELECT (
SELECT e."Value"FROM (
SELECTNULL::int4range AS _ord, NULL::int4range AS"Value"WHERE FALSE
) AS e
WHERE e."Value" && b."Seats"ORDER BYe._ordLIMIT1)
FROM"Bookings"AS b
The same query over a non-empty list writes FROM (VALUES (0, @full1), (1, @full2)) AS f(_ord, "Value"), an integer _ord. On release/10.x the EF Core 10.0.0/10.0.1 path writes 0 for it (OneRowOfNulls).
This is latent. Under WHERE FALSE no row exists, and ORDER BY over a range-typed NULL is valid SQL, so nothing fails today. A shape in which EF Core compares _ord with an integer would fail on the server, for the empty list only, with operator does not exist: int4range = integer.
Found by the review of PR #292 on 2026-10-19, and reproduced since.
Change
Leave _ord out of the cast in TypeTheNulls (match the projection alias, as OneRowOfNulls does on 10.x) and write it as an integer, the type it has when the list has elements. Assert the whole subquery of the FirstOrDefault shape in RangeCollectionTranslationTests, and prove the test by reverting the change.
Release
Not silent: no answer changes. #327 asks whether the cast belongs in the type mappings instead. The port to release/10.x is #325.
Activity