Repository navigation
fix: Any and Count over a captured list of ranges read the list from VALUES - #172
Merged
Merged
Conversation
…VALUES Any, Count and other LINQ over a captured list of ranges that no Contains read went to PostgreSQL as one parameter, which Npgsql typed as a multirange. unnest of a multirange merges overlapping and adjacent ranges and drops empty ones, so Count(w => w.Overlaps(r.Seats)) over [1,5] and [3,8] was 1 where memory says 2, and withEmpty.Any(w => w.IsEmpty()) was false, without an error. Any(w => w == c) failed loudly with 42809 and every Any or Count over a TimeRange list threw InvalidCastException. 9.1.0 fixed only the Contains case (#71), because the rest changed an answer and waited for the major. Every captured range collection is now sent one parameter per range, as a value set collection already is, so Any and Count read the list from VALUES and the list is the list; EF.Parameter(wanted) is refused for every use of a range collection, with the message saying why. An empty list reads no rows through the EmptyCollectionRewriter, which is why that fix precedes this one. The set-collection seed is refreshed against the new interceptor and still caught; claim E38 is restated as the parity it now is; the #76 candidate is removed. With the interceptor change reverted, four translation tests, three executed tests and CapturedCollectionProbeTests (1,710 lines) fail for the defect. Closes #76 Found-By: OT Defect-Class: SQL Co-Authored-By: Claude Fable 5.1 <[email protected]>
…collection-any-count
…collection-any-count # Conflicts: # CHANGELOG.md # docs/migration.md # test/oracles/candidates.json
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 #76
Stacked on #170 (
fix/empty-captured-collection) → #169 → #168 → #167: merge those first, then retarget this tomain. #170 goes first because this change would otherwise turn an empty range list from a correct answer into EF Core's "Empty collections are not supported as inline query roots".Problem
Any,Countand other LINQ over a captured list of ranges that noContainsread went to PostgreSQL as one parameter. Npgsql typed it as a multirange, so the query read it throughunnestof a multirange, which merges overlapping and adjacent ranges and drops empty ones:wanted.Count(w => w.Overlaps(r.Seats))over[1,5]and[3,8]was 1 where memory says 2,withEmpty.Any(w => w.IsEmpty())wasfalse, all without an error.CapturedCollectionProbeTestsmeasured it wider: every range type and collection form;Any(w => w == c)failing loudly with42809; and everyAny/Countover aTimeRangelist throwingInvalidCastException. 9.1.0 had fixed only theContainscase (#71) because the rest changed an answer, which by the release rule waits for the major.Change
src/CodoMetis.ValueRanges.EFCore.PostgreSQL/Query/ValueRangesQueryExpressionInterceptor.cs: every captured range collection is switched toParameterTranslationMode.MultipleParameters, as a value set collection already was; theContainsSourceCollectorand its limit are gone.AnyandCountread the list fromVALUES (@p1), (@p2), …, one typed parameter per range, so the list is the list.EF.Parameter(wanted)is refused for every use of a range collection, as it is for sets, with the message saying why and what to write. An empty list reads no rows through fix: Any and Count over an empty captured collection read no rows instead of throwing #170.test/oracles/seeds/set-collection-sent-as-one-parameter.patch: refreshed against the new interceptor (the defect it plants is unchanged: value set collections not switched);dotnet run tools/oracles.cs seeds set-collection-sentproves it is still caught.test/oracles/candidates.json: the Any/Count over a captured list of ranges silently merge overlapping ranges and drop empty ones #76 row removed.claims.json: E38 restated as the parity it now is (E38-captured-range-collection-any-count), quoting the new guide sentence, held byRangeCollectionContainsTests,RangeCollectionTranslationTestsandCapturedCollectionProbeTests.docs/efcore.md(list of ranges):Any/Countread fromVALUES, an empty list matches nothing, theEF.Constantworkaround is retired,EF.Parameterthrows everywhere.CHANGELOG.md,src/CodoMetis.ValueRanges.EFCore.PostgreSQL/CHANGELOG.md: the Breaking row;docs/migration.md:Check Any and Count over a captured list of ranges.Tests
RangeCollectionTranslationTests:AnyAlone_OverACapturedList_ReadsTheRangesFromValues,CountAlone_…,AnyAlone_OverAnEmptyCapturedList_ReadsNoRows,AnyAlone_OverEFParameter_IsRefusedWithWhatToWriteInstead.RangeCollectionContainsTests(PostgreSQL):AnyAndCountAloneOverTheCollection_AnswerAsInMemoryover overlapping, adjacent, duplicate and with-an-empty-range lists throughCount(Overlaps),Count(==),Any(==),Any(IsEmpty)andCount(IsAdjacentTo);AnEmptyCollectionAlone_AnyAndCountAnswerAsInMemory;AnyAloneOverTheCustomTimeRange_AnswersAsInMemory;AnyAloneOverEFParameter_IsRefusedWithWhatToWriteInstead.CapturedCollectionProbeTests.Ranges_AnswerAsInMemorypasses with its Any/Count over a captured list of ranges silently merge overlapping ranges and drop empty ones #76 candidate gone: every form × list × operation of all eleven range types agrees with memory.DateRange over adjacent as Array, alone: Count(Overlaps) for (,) → memory=2, database=1) fail.🤖 Generated with Claude Code