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
A widening the translator leaves out is a cast in EF Core's query: x.Int == 5L is stored as {Int} = 5, and the index does not serve "Int"::bigint = 5 #125
area/expression-indexesExpression, typed lambda and JSON member indexesbugSomething isn't workingpackage/coreAffects CodoMetis.EFCore.SchemaKit (the kernel)severity/lowCosmetic, message or documentation-level difference
Found while fixing #103, by crossing the parity sweep with the new table of conversions the translator leaves out (LambdaTranslator.SilentConversions). Until then the sweep compared a column only with a value of its own type.
What happens
For a comparison of two integer types the C# compiler widens the narrower side: x.Int == 5L arrives as Convert(x.Int, Int64) == 5. The translator leaves the conversion out, which keeps the answer: {Int} = 5. EF Core's query for the same lambda writes it:
-- the declaration -- EF Core's query"Int"=5 p."Int"::bigint=5"Short"<"Long" p."Short"::bigint< p."Long""Byte"=5-- (ushort)x.Byte p."Byte"::int = 5"Byte"=5-- x.Byte == 5ul p."Byte"::numeric(20,0) = 5.0
Both select the same rows (the live sweep runs every such row on PostgreSQL 18). But PostgreSQL uses a partial index only for a query whose predicate it can prove from the index's, and it does not look through the cast:
createindexixon t("Id") where"Int"=5;
explain select"Id"from t where"Int"=5; -- Index Only Scan using ix
explain select"Id"from t where"Int"::bigint=5; -- Seq Scan, Filter: (("Int")::bigint = 5)
So a filter declared with such a comparison is right about its rows and does not serve the query written with the same lambda, which is the reason the translator spells things as the provider's queries do. Nothing is cast where both types have one store type (byte and short are both smallint on PostgreSQL), so which widenings are affected is the provider's type mapping, not C#'s.
Change
When casts are rendered with the provider's spelling (#112, #114), a widening whose two types have different store types is written as the provider's query writes it. Until then the 432 rows are waived in waivers.txt under "A widening EF Core writes as a cast", and the block shrinks to nothing with the fix.
area/expression-indexesExpression, typed lambda and JSON member indexesbugSomething isn't workingpackage/coreAffects CodoMetis.EFCore.SchemaKit (the kernel)severity/lowCosmetic, message or documentation-level difference
Activity