Repository navigation
Fix LeftJoin, RightJoin and FullJoin matching null keys - #623
Merged
Merged
Conversation
This was referenced Oct 12, 2026
This was referenced Oct 13, 2026
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.
Bug
The
LeftJoin,RightJoinandFullJoinpolyfills were built onToLookup+lookup[key].ToLookupkeeps a group for thenullkey, so an element with anullkey was joined to every element on the other side that also had anullkey.The BCL never matches a
nullkey, not even with anothernullkey. For outer[(1,"a"),(2,null),(3,"b")]and inner[(10,"a"),(20,null),(30,"c")],LeftJoingives1-10, 2-0, 3-0, while the polyfill gave1-10, 2-20, 3-0.FullJoinhad a second problem: it recordednullas a seen outer key, sonullkeyed inner elements were dropped from the unmatched tail.Fix
LeftJoin/RightJoin: only probe the lookup when the key is not null.FullJoin:nullkeyed inner elements are kept out of the lookup and yielded last as unmatched (the order net11 uses), andnullis not recorded as a seen outer key.Test
IEnumerableLeftJoinNullKeysDoNotMatch,IEnumerableRightJoinNullKeysDoNotMatchandIEnumerableFullJoinNullKeysDoNotMatchjoin two sequences that both containnullkeys and duplicated keys, and assert the full ordered result. The expected values were taken from the BCL on net11. All three failed on net48 before the fix, and pass on net48, net8.0 (polyfill), net10.0 (BCLLeftJoin/RightJoin, polyfilledFullJoin) and net11.0 (BCL).