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

Query: incorrect results for queries projecting collections with distinct/group by, where we use projection as identifiers and all the columns are nullable #31277

Open
maumar opened this issue Jul 16, 2023 · 1 comment
Assignees
Labels
area-query breaking-change punted-for-8.0 Originally planned for the EF Core 8.0 (EF8) release, but moved out due to resource constraints. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented Jul 16, 2023

To mitigate the problem with insufficient information in case of Distinct and GroupBy, we use the projection/ group key as identifiers (see #22049). However, this is not correct if all the would-be identifiers are nullable. If that's the case and the values of all those columns would be null, we are not able to distinguish between empty set and set containing null value. (in fact, we would treat every null value as a new empty collection).

We should detect this and throw to prevent data corruption. (This is a breaking change - bad results only happen in case of null values, so if one has nullable columns without null values, everything was working fine, and now it would throw)

@roji
Copy link
Member

roji commented Jul 19, 2023

Just to avoid any doubts, this doesn't ever affect entity projections, since there's always a non-nullable key. So this only affects collections of non-entity types.

One possible direction here to to add a row number after e.g. the distinct/set operation/whatever; the row number would function as a unique thing we can use as the identifier.

@ajcvickers ajcvickers added the punted-for-8.0 Originally planned for the EF Core 8.0 (EF8) release, but moved out due to resource constraints. label Sep 6, 2023
@ajcvickers ajcvickers modified the milestones: 8.0.0, Backlog Sep 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-query breaking-change punted-for-8.0 Originally planned for the EF Core 8.0 (EF8) release, but moved out due to resource constraints. type-bug
Projects
None yet
Development

No branches or pull requests

4 participants