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 narrowing cast in a lambda is left out of the template: (int)x.Amount == 2 is stored as {Amount} = 2 #103
area/expression-indexesExpression, typed lambda and JSON member indexesbugSomething isn't workingpackage/coreAffects CodoMetis.EFCore.SchemaKit (the kernel)severity/mediumInconsistency or failure in a narrow scenariosilentAnswers wrongly without throwing; the fix ships as a minor, never a patch
Found by the pre-preview sweep of main @ 948496a (GPT's read of the translator; reproduced in a scratch test).
What happens
pg.Exclusion(pg.Overlaps(x =>x.Period),where: x =>(int)x.Amount==2,name:"ex_cast")// Amount is a decimal
is stored as {Amount} = 2 and reaches the database as
ALTERTABLE gigs ADD CONSTRAINT ex_cast EXCLUDE USING gist ("Period" WITH &&) WHERE ("Amount"=2);
For Amount = 2.5 the lambda is true and the predicate false: the row is outside the constraint. Nothing is refused. EF Core's own query for the same lambda keeps the cast.
Why
LambdaTranslator.Visit drops every Convert node (LambdaTranslator.cs:460), and so do the operands of a comparison (:272). That is right for the conversions the compiler adds (to Nullable<T>, to object, a widening between integer types the database compares alike) and wrong for a cast the consumer wrote that changes the value.
Change
A conversion between numeric types that can change the value is refused where the lambda is written, like the other constructs outside the tables, or written as the provider's query writes it and added to the parity sweep. Since the accepted constructs are data, the allowed conversions become a table the sweep and the analyzer (#31) read.
Test
LambdaTranslatorTests: the cast above refused or rendered; the lifts and widenings that must stay silent each as a row; the sweep's row for it.
area/expression-indexesExpression, typed lambda and JSON member indexesbugSomething isn't workingpackage/coreAffects CodoMetis.EFCore.SchemaKit (the kernel)severity/mediumInconsistency or failure in a narrow scenariosilentAnswers wrongly without throwing; the fix ships as a minor, never a patch
Activity