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
Typed filters: a date or time JSON member compared with a column fails at apply (text against timestamp) #119
A typed filter that compares a date or time member of a ToJson() document with a column scaffolds, then fails at apply:
b.HasComplexIndex(x =>x.Id, x =>x.Profile.At<x.ValidFrom,indexName:"ix_at");
CREATEINDEX "ix_at" ON accounts ("Id") WHERE ("profile"->>'At') <"ValidFrom";
-- ERROR: operator does not exist: text < timestamp with time zone
Since 5.4.0 a DateTime, DateTimeOffset, DateOnly or TimeOnly JSON member resolves to text, because the cast EF Core's queries use (CAST(... AS timestamp with time zone)) is not IMMUTABLE and cannot appear in an index. In a filter the text then meets a typed column. A comparison with a literal date is already refused at the declaration (dates have no portable literal), so only a comparison with another column or member reaches the database. Exclusion constraint filters, which keep the pre-5.4.0 rendering, fail the same way.
Fix
The translator cannot see that a path is a JSON member; the differ can. Refuse at migrations add a filter placeholder that resolves to a date or time JSON member's text fallback, naming the member and the string filter overload, the way ValidateQueryUsableLeadingParts refuses a non-unique index that starts with one. The place is the filter resolution (CustomMigrationsModelDiffer.ResolveFilter with NpgsqlComplexIndexMigrationsModelDiffer.ResolveUnmappedPart), outside the typed translator.
Loud. Found by the translator parity sweep (#101).
Activity