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 float literal is written with its shortest digits, and PostgreSQL compares it as double precision: x.Ratio == 0.1f matches no row that holds 0.1f #127
area/expression-indexesExpression, typed lambda and JSON member indexesbugSomething isn't workingpackage/coreAffects CodoMetis.EFCore.SchemaKit (the kernel)severity/lowCosmetic, message or documentation-level differencesilentAnswers wrongly without throwing; the fix ships as a minor, never a patch
Found while fixing #103, when deciding whether float to double may be left out of a template. Not caused by it.
What happens
where: x =>x.Ratio==0.1f// Ratio is a float, a real column
is stored as {Ratio} = 0.1. PostgreSQL reads 0.1 as numeric and compares real = numeric as double precision, where the column's value is 0.100000001490116 and the literal 0.1:
selectcount(*) filter (where"Flt"=0.1), count(*) filter (where"Flt"=0.1::real) from t; -- every row holds 0.1::real-- 0 | 20000
In C# the lambda is true for those rows. The predicate is false for all of them, so the constraint or the index covers none. It shows only for a value a float does not hold exactly; the sweep's sample is 5.5f, which it does, and that row agrees with EF Core's query, so EF Core appears to write the literal bare as well (not checked for 0.1f).
Related, and changed by #103: a float captured and compared with a double column is now converted before it is written (0.1f as 0.10000000149011612), which is the value C# compares.
Change, to decide
A literal carries its type where the provider's untyped literal is read as another one (0.1::real on PostgreSQL), written by the provider's package (#112, #114). Whether that still serves EF Core's query is the parity sweep's to say, with a sample that is not exact in binary.
Test
A parity row with 0.1f on a real column, run live.
area/expression-indexesExpression, typed lambda and JSON member indexesbugSomething isn't workingpackage/coreAffects CodoMetis.EFCore.SchemaKit (the kernel)severity/lowCosmetic, message or documentation-level differencesilentAnswers wrongly without throwing; the fix ships as a minor, never a patch
Activity