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 exclusion-constraint filters on non-string JSON members fail at apply (text > integer) #78
area/constraintsTemporal (WITHOUT OVERLAPS, PERIOD) and exclusion constraintsbugSomething isn't workingpackage/postgresqlAffects EFCore.ComplexIndexes.PostgreSQLseverity/mediumInconsistency or failure in a narrow scenario
A typed filter on an exclusion constraint that compares a non-string ToJson() member scaffolds SQL PostgreSQL rejects when the migration is applied:
b.HasExclusionConstraint(x =>x.Count, x =>x.Period, x =>x.Doc.Rank>5);// Rank: int// WHERE (("doc" ->> 'Rank') > 5) → 42883 operator does not exist: text > integerb.HasExclusionConstraint(ex =>ex.WithEquality(x =>x.Count).WithOverlaps(x =>x.Period).HasFilter(x =>x.Doc.Active));// Active: bool// WHERE (("doc" ->> 'Active')) → 42804 argument of WHERE must be type boolean, not type text
Both fail on PostgreSQL 16 and 18. docs/postgresql-constraints.md promises both JSON-member extraction and the typed-filter subset for exclusion filters.
Cause: BuildExclusionDescriptors resolves exclusion filters with renderingVersion: 1, which pins the pre-5.4.0 text-only JSON rendering so existing constraints never rebuild. The index path renders the same predicate as CAST(("doc" ->> 'Rank') AS integer) > 5 and applies.
Fix
Use the 5.4.0 rendering for non-string JSON leaves in exclusion filters. Under rendering 1 those filters never applied, so no existing constraint changes; string leaves keep rendering 1.
Loud (fails at apply), so it can ship in a patch. Found by the 5.5.0 pre-tag analysis (PostgreSQL satellite); present since 5.4.0.
Scope as built in #108: rather than every non-string leaf, the switch to the 5.4.0 rendering covers the leaves that rendering casts (numbers, booleans, uuid, enums). Primitive collections, json/jsonb, bytea and the date/time text fallbacks keep rendering 1, because the current rendering reads a primitive collection with -> (jsonb) where rendering 1 used ->> (text), and the two treat a JSON null differently, so {Doc.Tags} IS NOT NULL would have changed meaning. A cast keeps NULL as NULL. Also, "never applied" holds for comparisons and bare booleans; {Doc.Rank} IS NOT NULL did apply under rendering 1, but it holds for the same rows when cast, and both sides of the diff resolve alike, so it gets no migration.
area/constraintsTemporal (WITHOUT OVERLAPS, PERIOD) and exclusion constraintsbugSomething isn't workingpackage/postgresqlAffects EFCore.ComplexIndexes.PostgreSQLseverity/mediumInconsistency or failure in a narrow scenario
Activity
CaffeinatedCoder commentedon Oct 20, 2026
Scope as built in #108: rather than every non-string leaf, the switch to the 5.4.0 rendering covers the leaves that rendering casts (numbers, booleans, uuid, enums). Primitive collections,
json/jsonb,byteaand the date/time text fallbacks keep rendering 1, because the current rendering reads a primitive collection with->(jsonb) where rendering 1 used->>(text), and the two treat a JSON null differently, so{Doc.Tags} IS NOT NULLwould have changed meaning. A cast keeps NULL as NULL. Also, "never applied" holds for comparisons and bare booleans;{Doc.Rank} IS NOT NULLdid apply under rendering 1, but it holds for the same rows when cast, and both sides of the diff resolve alike, so it gets no migration.Merge pull request #108 from CaffeinatedCoder/fix/78-exclusion-json-f…