Repository navigation
fix(postgresql): refuse a filter comparing a JSON date member with a column - #128
Merged
Merged
Conversation
…column (#119) Since 5.4.0 a date or time member of a ToJson() document resolves to its text, because the cast EF Core's queries use is not IMMUTABLE and cannot appear in an index. In a filter that text met a typed column: x => x.Profile.At < x.ValidFrom scaffolded ("profile" ->> 'At') < "ValidFrom", and PostgreSQL refused it at apply with "operator does not exist: text < timestamp with time zone". Exclusion constraint filters, pinned to rendering 1, failed the same way. ResolveFilter now knows which placeholders resolved to such a text fallback and refuses a comparison of one with a column or another typed placeholder at migrations add, naming the member. A null test and a comparison with a string literal still apply, as before. The Npgsql differ flags those members under rendering 1 for exclusion filters too. This touches the core differ and the Npgsql differ, outside the typed translator: the edits are confined to filter resolution. Verified with the change reverted: the three refusal tests fail (the exclusion case also with only the Npgsql line reverted). The parity sweep's 24 rows for it now fail at migrations add instead of rendering. Co-Authored-By: Claude Opus 5.5 <[email protected]>
CaffeinatedCoder
changed the base branch from
fix/118-null-check-shapes
to
main
October 20, 2026 07:14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #119
Stacked on #126 (#118) → #124 (#117) → #123 (#94) → #122 (#80) → #121 (#101); merge those first.
Problem
Since 5.4.0 a
DateTime,DateTimeOffset,DateOnlyorTimeOnlymember of aToJson()document resolves to its text, because the cast EF Core's queries use is not IMMUTABLE and cannot appear in an index. In a filter, the text met a typed column:scaffolded
WHERE ("profile" ->> 'At') < "ValidFrom", and PostgreSQL refused the migration at apply:operator does not exist: text < timestamp with time zone(reproduced on PostgreSQL 18). Exclusion constraint filters, which stay on rendering 1, failed the same way. The parity sweep (#101) found it: 24 rows.Change
This is outside the typed translator. The typed translator cannot see that a path is a JSON member; only the differ can. Both edits are confined to filter resolution:
CustomMigrationsModelDiffer.ResolveFilter(core, stream C's file): records which placeholders resolved to a text fallback, and refuses one compared (=,<>,<,<=,>,>=) with a quoted column or another typed placeholder, on either side, naming the member and the alternatives. A null test, a comparison with a string literal and every other use resolve as before.ResolvePlaceholderreturns the part'sTextFallback.NpgsqlComplexIndexMigrationsModelDiffer.ResolveUnmappedPart(stream B's file): under rendering 1, an exclusion filter's member that falls back to text under the current rendering is flagged the same way. Nothing else changes for rendering-1 parts.waivers.txt: the 24 rows now fail atmigrations addby design; their block says so.### Fixedline (root and PostgreSQL),docs/postgresql-indexes.md(JSON member indexes), CLAUDE.md (theTextFallbackparagraph).Not breaking: every refused filter failed at apply before.
Tests
NpgsqlJsonDateFilterTests: a typed filter, a column-first string filter and an exclusion constraint filter that compare a JSON date member with a column are refused atmigrations add;IS NOT NULL, a string literal and a typed JSON member compared with a column still resolve.🤖 Generated with Claude Code