Fix ExpressionHasher constant collision#9765
Open
apereiratl wants to merge 6 commits into
Open
Conversation
VisitConstant was not overridden, so predicates that differ only in their constant values hashed identically — collapsing aliased [UseFiltering] DataLoader branches into one.
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes ExpressionHasher collisions when two predicates differ only by constant values, which previously caused aliased [UseFiltering] DataLoader branches to collapse into one due to identical hashes.
Changes:
- Adds
VisitConstanthandling inExpressionHasherso constant values participate in hashing. - Expands unit coverage to ensure predicates with different constants (including captured variables) hash differently.
- Updates an existing buffer-resize test to account for the new constant hashing payload size.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/GreenDonut/src/GreenDonut.Data/Internal/ExpressionHasher.cs | Adds constant-expression hashing and value serialization logic to avoid constant-based hash collisions. |
| src/GreenDonut/test/GreenDonut.Data.Tests/Internal/ExpressionHasherTests.cs | Updates existing hash expectation and adds regression tests for constant/captured-variable hashing; adjusts buffer resize test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…tionTests.cs, with a small BooksByAuthorPagedDataLoader and an [ExtendObjectType<Author>]. It runs two aliased [UseFiltering] calls against a StatefulBatchDataLoader<int, Page<Book>>, differing only in the title eq "..." constant. Pre-fix both aliases collapsed onto one branch; post-fix the snapshot has them returning their respective single matches.
Author
|
Hi @tobias-tengler I've fixed all the review comments. Please re-review and let me know if there's anything else. Thank you. |
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.
VisitConstant was not overridden, so predicates that differ only in their constant values hashed identically, collapsing aliased [UseFiltering] DataLoader branches into one.