Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Avoid applying null semantics expansion to joins between composite keys #16265

Closed
divega opened this issue Jun 26, 2019 · 1 comment
Closed
Assignees
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Milestone

Comments

@divega
Copy link
Contributor

divega commented Jun 26, 2019

In the discussion at #15798 (comment), we agreed that we will stick to the principle that when we traverse relationships (essentially, performing an equality comparisons between keys), null values should not be considered equal, therefore we should not use null semantics.

This principle applies to anything generated by navigation expansion, as well as to ad-hoc relationships established by join operations.

In LINQ to Objects, Join() for simple keys follows this same rule: two values of a nullable type that are null are not considered a match. But for anything more complicated, Join() relies on the equality comparer at hand, which is usually implemented using null semantics. For examples, a join between new {A = 1, B = null} and new {A = 1, B = null} is a match because the comparer of anonymous types just performs member by member comparison with client null semantics.

Join between composite keys in LINQ usually ends up being represented as joins between structural types, and hence when we translate them to SQL, we currently go out of our way to try to replicate the behavior of LINQ to objects.

I believe that doing so can produce unnecessarily complex queries and also results that don't align with how composite key joins normally work on databases.

@maumar
Copy link
Contributor

maumar commented Dec 5, 2019

this is fixed now

@maumar maumar closed this as completed Dec 5, 2019
@maumar maumar modified the milestones: Backlog, 3.1.0 Dec 5, 2019
@maumar maumar self-assigned this Dec 5, 2019
@maumar maumar added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Dec 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-enhancement
Projects
None yet
Development

No branches or pull requests

4 participants