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: data corruption for queries with set result operators (Concat/Union etc) and collection navigations #8524

Closed
maumar opened this issue May 19, 2017 · 2 comments
Assignees
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Milestone

Comments

@maumar
Copy link
Contributor

maumar commented May 19, 2017

query:

context.Gears.Select(g => g.Weapons.Concat(g.Weapons)).ToList()

produces bad QM:

from Gear g in DbSet<Gear>
select 
    (from Weapon <generated>_1 in DbSet<Weapon>
    where Property([g], "FullName") ?= Property([<generated>_1], "OwnerFullName")
    where Property([g], "FullName") ?= Property([<generated>_1], "OwnerFullName")
    select [<generated>_1]).Concat({value(Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryable`1[Microsoft.EntityFrameworkCore.Specification.Tests.TestModels.GearsOfWarModel.Weapon])})

collection expansion predicate is applied twice to the outer query source, but is not applied to the inner one at all. This produces incorrect results (since there is no filter on the inner query source at all)

@maumar
Copy link
Contributor Author

maumar commented May 19, 2017

could be related to #8186

@ajcvickers ajcvickers added this to the 2.0.0 milestone May 22, 2017
maumar added a commit that referenced this issue Jul 1, 2017
#8524 - Query: data corruption for queries with set result operators (Concat/Union etc) and collection navigations
#8525 - Query: compilation error for queries with navigations inside set result operators and Count
#9004 - Query: compilation error for queries with Concat on two entities and Count

Problem was that for set result operators we always need to materialize both sets, even if they are wrapped around scalar result operator (e.g. Count). This is needed because set result operators are currently performed on the client.

Also, we need to inject MaterializeCollectionNavigation calls into set result operators, so that the IQuerySource that is the argument to the set operator is wrapped in its own query source.

Also fixed some minor bugs in the MaterializeCollectionNavigation injector, which surfaced once the visitor started going inside SubQueryExpressions (it wasn't necessary before because we only needed to materialize top level collection).
maumar added a commit that referenced this issue Jul 3, 2017
#8524 - Query: data corruption for queries with set result operators (Concat/Union etc) and collection navigations
#8525 - Query: compilation error for queries with navigations inside set result operators and Count
#9004 - Query: compilation error for queries with Concat on two entities and Count

Problem was that for set result operators we always need to materialize both sets, even if they are wrapped around scalar result operator (e.g. Count). This is needed because set result operators are currently performed on the client.

Also, we need to inject MaterializeCollectionNavigation calls into set result operators, so that the IQuerySource that is the argument to the set operator is wrapped in its own query source.

Also fixed some minor bugs in the MaterializeCollectionNavigation injector, which surfaced once the visitor started going inside SubQueryExpressions (it wasn't necessary before because we only needed to materialize top level collection).
maumar added a commit that referenced this issue Jul 5, 2017
#8524 - Query: data corruption for queries with set result operators (Concat/Union etc) and collection navigations
#8525 - Query: compilation error for queries with navigations inside set result operators and Count
#9004 - Query: compilation error for queries with Concat on two entities and Count

Problem was that for set result operators we always need to materialize both sets, even if they are wrapped around scalar result operator (e.g. Count). This is needed because set result operators are currently performed on the client.

Also, we need to inject MaterializeCollectionNavigation calls into set result operators, so that the IQuerySource that is the argument to the set operator is wrapped in its own query source.

Also fixed some minor bugs in the MaterializeCollectionNavigation injector, which surfaced once the visitor started going inside SubQueryExpressions (it wasn't necessary before because we only needed to materialize top level collection).
@maumar
Copy link
Contributor Author

maumar commented Jul 5, 2017

fixed in e1d7b16

@maumar maumar closed this as completed Jul 5, 2017
@ajcvickers ajcvickers added the closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. label Oct 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-fixed The issue has been fixed and is/will be included in the release indicated by the issue milestone. type-bug
Projects
None yet
Development

No branches or pull requests

2 participants