Repository navigation
Refuse a JSON date-vs-column filter on the target model only - #146
Merged
Merged
Conversation
ResolveFilter threw while building descriptors for both diff sides, so a snapshot holding such a filter could not be diffed, not even by the migration removing it. It now returns the refusal; the index and exclusion descriptors carry it outside equality, and the differs throw it for target descriptors only. Closes #144 Co-Authored-By: Claude Opus 5.5 <[email protected]>
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 #144
Problem
The check new in the unreleased 5.5.0 that refuses a filter comparing a date or time
ToJson()member with a column ran insideResolveFilter, which builds descriptors for both diff sides (and, for exclusion constraints,BuildExclusionDescriptors(source)). A snapshot holding such a filter, scaffolded by 5.4.x, could therefore never be diffed: removing the declaration mademigrations addthrow "compares the JSON member 'Profile.At' with a column" instead of emitting the drop, andhas-pending-model-changesandMigrate()'s pending-changes check failed the same way. That breaks the rule that validation runs on the target model only.Change
CustomMigrationsModelDiffer: the internalResolveFilteroverload returns the refusal throughout string? refusalinstead of throwing (ThrowIfFallbackComparedWithColumn→FallbackComparedWithColumn, message unchanged).IndexDescriptorcarries it asFilterRefusal, outside equality, and the newValidateFilterComparisons(targetIndexes)throws it next toValidateQueryUsableLeadingParts. The protectedResolveFilterkeeps throwing, so a subclass calling it sees no change.NpgsqlComplexIndexMigrationsModelDiffer:ExclusionDescriptorcarriesFilterRefusalthe same way, andApplyExclusionConstraintsthrows it for target constraints only, besideValidateUniqueExclusionNames.No changelog change: the 5.5.0 line ("fails at
migrations add") is still accurate, and the check has not shipped.Tests
Two new tests in
NpgsqlJsonDateFilterTests:NpgsqlDiff(snapshotWithFilter, modelWithout)emitsDropIndexOperation ix_at(index filter, snapshot pinned at rendering version 2), and theDROP CONSTRAINT IF EXISTS "ex_at"SQL (exclusion filter). With the source files reverted tomain, both fail with the refusal'sInvalidOperationException(2 failed, 4 passed in the class). The existing target-side refusal tests stay green, and so does the unit suite (TestCategory!=Integration&TestCategory!=SqlServer): 571 passed.🤖 Generated with Claude Code